Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24731] : iOS Resolve iOS 8 deprecations for willAnimateRotationToInterfaceOrientation #9138

Merged
merged 11 commits into from
Aug 8, 2017
9 changes: 6 additions & 3 deletions iphone/Classes/TiControllerProtocols.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
-(void)viewWillDisappear:(BOOL)animated;
-(void)viewDidAppear:(BOOL)animated;
-(void)viewDidDisappear:(BOOL)animated;
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator;
- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator;

//Focus callbacks from containing or hosting controller
-(void)gainFocus;
-(void)resignFocus;
Expand Down
106 changes: 24 additions & 82 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1286,11 +1286,7 @@ -(void)refreshOrientationWithDuration:(id)unused
#ifdef FORCE_WITH_MODAL
[self forceRotateToOrientation:target];
#else
if ([TiUtils isIOS8OrGreater]) {
[self rotateHostingViewToOrientation:target fromOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
} else {
[self manuallyRotateToOrientation:target duration:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]];
}
[self rotateHostingViewToOrientation:target fromOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
forcingRotation = NO;
#endif
} else {
Expand Down Expand Up @@ -1445,72 +1441,6 @@ -(void)rotateHostingViewToOrientation:(UIInterfaceOrientation)newOrientation fro

}

-(void)manuallyRotateToOrientation:(UIInterfaceOrientation)newOrientation duration:(NSTimeInterval)duration
{
if (!forcingRotation) {
return;
}
UIApplication * ourApp = [UIApplication sharedApplication];
UIInterfaceOrientation oldOrientation = [ourApp statusBarOrientation];
CGAffineTransform transform;

switch (newOrientation) {
case UIInterfaceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(M_PI);
break;
case UIInterfaceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(-M_PI_2);
break;
case UIInterfaceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(M_PI_2);
break;
default:
transform = CGAffineTransformIdentity;
break;
}

[self willRotateToInterfaceOrientation:newOrientation duration:duration];

// Have to batch all of the animations together, so that it doesn't look funky
if (duration > 0.0) {
[UIView beginAnimations:@"orientation" context:nil];
[UIView setAnimationDuration:duration];
}

if ((newOrientation != oldOrientation) && isCurrentlyVisible) {
TiViewProxy<TiKeyboardFocusableView> *kfvProxy = [keyboardFocusedProxy retain];
BOOL focusAfterBlur = [kfvProxy focused:nil];
if (focusAfterBlur) {
[kfvProxy blur:nil];
}
forcingStatusBarOrientation = YES;
[ourApp setStatusBarOrientation:newOrientation animated:(duration > 0.0)];
forcingStatusBarOrientation = NO;
if (focusAfterBlur) {
// -- TIMOB-23924 --
// For some reason, Apple thinks this is a private selector.
// Until they fix it, this is our workaround
[kfvProxy performSelector:NSSelectorFromString([NSString stringWithFormat:@"%@c%@:", @"fo", @"us"]) withObject:nil];
}
[kfvProxy release];
}

UIView * ourView = [self view];
[ourView setTransform:transform];
[self resizeView];

[self willAnimateRotationToInterfaceOrientation:newOrientation duration:duration];

//Propigate this to everyone else. This has to be done INSIDE the animation.
[self repositionSubviews];

if (duration > 0.0) {
[UIView commitAnimations];
}

[self didRotateFromInterfaceOrientation:oldOrientation];
}

#pragma mark - TiOrientationController
-(void)childOrientationControllerChangedFlags:(id<TiOrientationController>) orientationController;
{
Expand Down Expand Up @@ -1619,28 +1549,40 @@ -(void)viewDidDisappear:(BOOL)animated
}
[super viewDidDisappear:animated];
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[thisWindow viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
[self updateOrientationHistory:toInterfaceOrientation];
[self rotateDefaultImageViewToOrientation:toInterfaceOrientation];
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)[[UIDevice currentDevice] orientation];
[self updateOrientationHistory:interfaceOrientation];
[self rotateDefaultImageViewToOrientation:interfaceOrientation];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[thisWindow systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[super systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[thisWindow preferredContentSizeDidChangeForChildContentContainer:container];
}
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[super preferredContentSizeDidChangeForChildContentContainer:container];
}

#pragma mark - Status Bar Appearance
Expand Down
17 changes: 16 additions & 1 deletion iphone/Classes/TiUIScrollableViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,28 @@ -(CGFloat)autoHeightForSize:(CGSize)size
return result;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
if ([self viewAttached]) {
[(TiUIScrollableView*)[self view] manageRotation];
}
}

- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{

}

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{

}

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. No need to call super. These are end calls . These protocols are implemented here to play safe. If it get call from somewhere without check, app will ensure to not crash. Required changes for scrollview is implemented as per previous implementation , in method -

  • (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator


-(void)willChangeLayout
{
#ifndef TI_USE_AUTOLAYOUT
Expand Down
7 changes: 4 additions & 3 deletions iphone/Classes/TiUITabGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@

-(UITabBar*)tabbar;

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator;
- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator;
- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
@end

#endif
19 changes: 12 additions & 7 deletions iphone/Classes/TiUITabGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -432,25 +432,30 @@ -(void) setActiveTabIconTint_:(id)value
controller.tabBar.tintColor = color.color;
}
else {
controller.tabBar.selectedImageTintColor = color.color; //deprecated for >= ios8
controller.tabBar.tintColor = color.color;
}
}

#pragma mark Public APIs

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[controller viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[controller willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[controller willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
[controller willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[controller systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
[controller didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[controller preferredContentSizeDidChangeForChildContentContainer:container];
}

-(void)setTranslucent_:(id)value
Expand Down
37 changes: 20 additions & 17 deletions iphone/Classes/TiUITabGroupProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,29 +250,32 @@ - (void)viewDidDisappear:(BOOL)animated;
[super viewDidDisappear:animated];
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
if ([self viewAttached]) {
[(TiUITabGroup *)[self view] viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
if ([self viewAttached])
{
[(TiUITabGroup *)[self view] willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
if ([self viewAttached]) {
[(TiUITabGroup *)[self view] willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
if ([self viewAttached])
{
[(TiUITabGroup *)[self view] willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
if ([self viewAttached]) {
[(TiUITabGroup *)[self view] systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
if ([self viewAttached])
{
[(TiUITabGroup *)[self view] didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
if ([self viewAttached]) {
[(TiUITabGroup *)[self view] preferredContentSizeDidChangeForChildContentContainer:container];
}
}

-(UIStatusBarStyle)preferredStatusBarStyle;
Expand Down Expand Up @@ -320,4 +323,4 @@ -(void)willChangeSize

@end

#endif
#endif
19 changes: 17 additions & 2 deletions iphone/Classes/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,27 @@ -(BOOL)_handleClose:(id)args
return [super _handleClose:args];
}

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self willChangeSize];
}

- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
[super systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
[super preferredContentSizeDidChangeForChildContentContainer:container];
}

- (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
{
shouldUpdateNavBar = YES;
Expand Down
29 changes: 19 additions & 10 deletions iphone/Classes/TiUIiOSNavWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -416,28 +416,37 @@ -(void)resignFocus
[super resignFocus];
}

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
if ([self viewAttached]) {
[navController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[navController viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
if ([self viewAttached]) {
[navController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[navController systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[super systemLayoutFittingSizeDidChangeForChildContentContainer:container];
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
if ([self viewAttached]) {
[navController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[navController willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
}

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
{
if ([self viewAttached]) {
[navController preferredContentSizeDidChangeForChildContentContainer:container];
}
[super preferredContentSizeDidChangeForChildContentContainer:container];
}


#pragma mark - TiViewProxy overrides
Expand Down Expand Up @@ -480,4 +489,4 @@ -(void)willChangeSize

@end

#endif
#endif