I have custom UILabel which works fine on iOS6 and iOS7. But on iOS8 this label's (void)layoutSubviews method never get called. I create this label with initWithFrame, so this method should be called - and it's called on another iOS versions. What happens with autoLayout system in iOS8?
相关问题
- UITableViewCell layout not updating until cell is
- iOS autolayout - gap between image and top of the
- Loading local file in WKWebView doesn't workin
- getting NSLayoutConstraints associated view
- Xcode 6 Storyboard crashing when scrolling to part
相关文章
- Xcode: Is there a way to change line spacing (UI L
- Adding TapGestureRecognizer to UILabel in Swift
- Navigation bar disappears when typing in UISearchC
- iOS 8 Today widget alignment issue
- How to check if UILabel has attributedText or norm
- Determine last line's width
- Using the device simulator for iOS 8 with Xcode 7
- Using UILexicon to implement autocorrect in iOS 8
The bug was fixed by Apple in iOS 8.1 (beta).
I had same issue. Really layoutSubviews is not called anymore for UILabel on iOS8, as Apple does not expect anybody uses it as superview.
I am using ReactiveCocoaLayout, so it can be done by subscribing to rcl_frameSignal or rcl_boundsSignal.
-(void)awakeFromNib { [ self.rcl_boundsSignal subscribeNext: ^( NSValue* boundsValue ) { //layout changed } ]; }
Or you can use simple KVO to know when frame has been changed:
I just want to add this answer because the question title may lead a lot of ppl here with similar issues (like me).
With iOS 8 to 8.0.2
LayoutSubviews
calls are unreliable. They may not be called ever or (in my case) are called in a loop.Even though you should not do it, it was pretty safe to alloc stuff in LayoutSubviews, but with this buggy (?!) behaviour it can cause hard-to-trace bugs.
I don't know if 8.1 fixes all the issues but it will be some time until customer devices will run 8.1 and they do run 8.0.2 NOW