This transition supports both landscape and portrait modes and works on iOS 7 - iOS 8.2.
-
Controllers will not properly rotate if orientation changed when presented. There is only one exception, if presented controller is a navigation controller, then rotation works fine. Seems like UIKit bug.
-
State restoration is possible but presented VC should restore
transitioningDelegate
,modalPresentationStyle
andmodalPresentationCapturesStatusBarAppearance
. If you use storyboards then it's easy:- (void)encodeRestorableStateWithCoder:(NSCoder *)coder { [super encodeRestorableStateWithCoder:coder]; [coder encodeInteger:self.modalPresentationStyle forKey:@"modalPresentationStyle"]; [coder encodeInteger:self.modalPresentationCapturesStatusBarAppearance forKey:@"modalPresentationCapturesStatusBarAppearance"]; [coder encodeObject:self.transitioningDelegate forKey:@"transitioningDelegate"]; } - (void)decodeRestorableStateWithCoder:(NSCoder *)coder { [super decodeRestorableStateWithCoder:coder]; self.modalPresentationStyle = [coder decodeIntegerForKey:@"modalPresentationStyle"]; self.modalPresentationCapturesStatusBarAppearance = [coder decodeIntegerForKey:@"modalPresentationCapturesStatusBarAppearance"]; self.transitioningDelegate = [coder decodeObjectForKey:@"transitioningDelegate"]; }
This project is a part of my blog post. However lots of things changed since original blog post was published.
- Unwinding works fine if you fix
segueForUnwindingToViewController
in source navigation controller and create unwind segue using source view controller. Works for both iOS 7 and 8 (see http://stackoverflow.com/a/28607309/351305) - Resetting views' frames to container bounds before adding them to container helps to solve issues with misplaced navigation bar and rotation issues on iOS 7.