Auto Layout not centering subview in superview on iOS 8
| Originator: | beckcollin | ||
| Number: | rdar://17607852 | Date Originated: | 09-Jul-2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 8.0 GM |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: In iOS 8, depending on the ordering of the views in the centering constraint, the superview's frame will be adjusted instead of the subview's frame. In iOS 7, the subview's frame was always adjusted regardless of the views ordering in the centering constraint. Steps to Reproduce: # See attached sample project 1. Center a label in a superview with this code: 1. [NSLayoutConstraint constraintWithItem:containerViewTwo attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:labelTwo attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]; 2. [containerViewTwo setNeedsLayout]; 3. [containerViewTwo layoutIfNeeded]; 2. Observe containerViewTwo's frame and labelTwo's frame. 3. containerViewTwo's frame will have adjusted to be centered with labelTwo. Expected Results: labelTwo's frame would be adjusted to be in the center of containerViewTwo Actual Results: containerViewTwo's frame is adjusted (frame.x value is now negative) to be centered with labelTwo. Version: iOS 8.0 (12A4318c) Beta 3 Notes: See Sample Project and Screenshots Configuration: iPad Mini 32GB AT&T Attachments: 'ViewBasedPDF.zip', 'iOS 7 centered.png' and 'iOS 8 not centered.png' were successfully uploaded.
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!