Layout guides are incorrect when view presented by custom navigation controller transition
| Originator: | miles.chris | ||
| Number: | rdar://15590606 | Date Originated: | 05-Dec-2013 |
| Status: | Duplicate | Resolved: | 20-Dec-2013 |
| Product: | iOS SDK | Product Version: | |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
When a custom navigation controller transition animation is used to present a new viewcontroller, the destination view controller's views are laid out incorrectly if any autolayout constraints reference the layout guides.
In these cases, the layout guides are incorrectly zero points high, rather than the height needed to layout below the navigation bar and above the toolbar.
The layout does not match the result of the same view controller presented by the default navigation controller transition (i.e. when no custom animation used).
Steps to Reproduce:
1. Set up a navigation controller with a delegate returning a custom UIViewControllerAnimatedTransitioning object.
2. In the custom UIViewControllerAnimatedTransitioning object, implement any animation to transition to the destination view controller.
3. Create a destination view controller with a view containing subviews laid out relative to the top and/or bottom layout guides. For example:
UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
contentLabel.text = @"Top Content";
contentLabel.font = [self contentFont];
contentLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:contentLabel];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:contentLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0f constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:contentLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0]];
4. In code, push the destination view controller on to the navigation stack.
5. Compare the resulting layout with that of pushing the same destination view controller when no custom transition is set.
Expected Results:
The destination view should appear with subviews laid out below the top layout guide (or above bottom layout guide) as expected. The layout should match the layout when no custom transition is used.
In other words, the layout guides should correctly reflect the overlapping sizes of the top/bottom bars.
Actual Results:
When a custom transition is used, the destination view layout is incorrect, and does not match the layout when no custom transition is used. The layout incorrectly calculates top/bottom layout guides with heights of zero, causing subviews to be incorrectly placed under navigation bars and toolbars.
Version:
Reproduced on iOS 7.0.3 (11B508) Simulator, and 7.0.4 (11B554a) iPad Air device.
Notes:
A sample project is attached, demonstrating the difference when presenting the same view via custom navigation controller transition vs default transition.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
I've experienced the same. I just duplicated your report.
I noticed that the layout will be "fixed" if you present a modal VC after pushing and then dismiss that – which makes no sense at all... :(