UITextField query it's `intrinsicContentSize` and call `layoutSubviews` in the initializer on iOS 11.0 (15A5318g)
Originator: | alessandro.calzavara | ||
Number: | rdar://33423712 | Date Originated: | 07/20/2017 |
Status: | Open | Resolved: | |
Product: | iOS | Product Version: | 11.0 (15A5318g) |
Classification: | Reproducible: | Always |
Area: UIKit Summary: On iOS11, UITextField query it's `intrinsicContentSize` and call `layoutSubviews` inside the initializer. On iOS10 and below, `intrinsicContentSize` and `layoutSubviews` are called only after the view is added to its superview. This means that, when subclassing UITextField for adding custom UI elements, I need to trick the system with wrong values until the view is actually added to its superview. Steps to Reproduce: This is a simple subclass of UITextField with char counter at the bottom. https://gist.github.com/dral3x/35c86d1c3645bae81de73487a1765239 Expected Results: The Playground should run correctly and the instance of SPKTextField should be visible. Observed Results: The Playground crashes, because `intrinsicContentSize` and `layoutSubviews` are called too early (during the super.init call) Version: 11.0 (15A5318g) Notes: This issue happens also if the code is compiled with iOS10 SDK
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!