Created
October 17, 2014 08:14
-
-
Save jcayzac/a38d835c345c76b0f506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only called on iOS<8 | |
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation __unused)toInterfaceOrientation duration:(NSTimeInterval __unused)duration { | |
[self _beforeOrientationChange]; | |
} | |
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation __unused)fromInterfaceOrientation { | |
[self _afterOrientationChange]; | |
} | |
// Only called on iOS>8 | |
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { | |
[self _beforeOrientationChange]; | |
UIInterfaceOrientation oldOrientation = UIApplication.sharedApplication.statusBarOrientation; | |
typeof(self) __weak weakSelf = self; | |
[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> __unused context) { | |
if (oldOrientation != UIApplication.sharedApplication.statusBarOrientation) { | |
typeof(weakSelf) __strong strongSelf = weakSelf; | |
[strongSelf _afterOrientationChange]; | |
} | |
}]; | |
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; | |
} | |
- (void)_beforeOrientationChange { | |
// your code here | |
} | |
- (void)_afterOrientationChange { | |
// your code here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment