UIScrollView layoutSubviews behavior changes in iOS 5?

自作多情 提交于 2019-12-24 01:23:48

问题


I'm working on a component that is a subclass from UIView and contains a UIScrollView. When scrolling, I noticed different behaviors depending on which SDK I build with. On iOS 4 the layoutSubviews message is send on the scroll view's superview (which is my component) but on iOS 5 it seems that the message is not send anymore...

After taking a look at the iOS 5 release notes and changelog, I did not find any mention of such a change. Did I miss somethin?


回答1:


In iOS5, layoutSubviews is not called on a scrollView's superview. But it was in iOS4.

If you want this behavior in iOS5, do this in your subclass of UIScrollView:

- (void)layoutSubviews {
    [super layoutSubviews];

    // causes layoutSubviews to get called on superview
    [self.superview setNeedsLayout]; 

This was probably changed to be more efficient. Just because UIScrollView is scrolling, doesn't mean it's superview needs to layout itself.




回答2:


I had big probs with resizing the size of button witch was subview in tableview. The nib loaded the smaller button and after loading I resize it. But the table view content didn't. (In iOS 4.* it was perfect but in iOS 5). So I figured out that I have to place my resizing in ViewDidLoad. I hope it helps to some1 =)



来源:https://stackoverflow.com/questions/8036457/uiscrollview-layoutsubviews-behavior-changes-in-ios-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!