Autolayout does not work (crashes) when used in UICollectionView subviews.
| Originator: | KevinRLundberg | ||
| Number: | rdar://12662425 | Date Originated: | 11/08/2012 |
| Status: | Closed | Resolved: | No |
| Product: | iOS | Product Version: | 6.0 |
| Classification: | Crash | Reproducible: | Yes |
Summary: If you try to add NSLayoutConstraints to subviews of a uicollectionview (cells or supplementary views exhibited this behavior, I havent tried decoration views) then the application crashes when you try to display the view. Subclassing UICollectionView and overriding layoutSubviews to call updateConstraints does not bypass the issue. Happens on both iPad and iPhone. The following message shows up in the logs when this happens: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UICollectionView's implementation of -layoutSubviews needs to call super.' *** First throw call stack: (0x1c99012 0x10cbe7e 0x1c98e78 0xb61f35 0x6299f 0x10df6b0 0x2295fc0 0x228a33c 0x2295eaf 0x1018bd 0x4a156 0x48c6f 0x48b89 0x47de4 0x47c1e 0x489d9 0x4b8d2 0xf5f9c 0x42b74 0x42d6f 0x42f05 0x4bf17 0xff6c 0x10f4b 0x222b5 0x231eb 0x14c98 0x1bf4df9 0x1bf4ad0 0x1c0ebf5 0x1c0e962 0x1c3fbb6 0x1c3ef44 0x1c3ee1b 0x1077a 0x125fc 0x1bfd 0x1b25) libc++abi.dylib: terminate called throwing an exception Steps to Reproduce: in a plain collectionview, have it dequeue a cell or supplementary view, and attempt to add one or more NSLayoutConstraints to the view. Expected Results: Autolayout should work in these scenarios. Actual Results: App crashes with an exception that happens entirely in system code. Regression: Doubtful; this is apparent in the iOS 6 simulator shipped with xcode 4.5, so unless it worked with the betas it's been there from the beginning. Notes: Sample project attached to bug in apple's system.
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!
This also only happens with constraints made in code. Constraints made in xib files don't exhibit this crashy behavior.