iOS 5 中的 UIScrollView layoutSubviews 行为变化? [英] UIScrollView layoutSubviews behavior changes in iOS 5?

查看:17
本文介绍了iOS 5 中的 UIScrollView layoutSubviews 行为变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个组件,它是 UIView 的子类并包含一个 UIScrollView.滚动时,我注意到不同的行为取决于我构建的 SDK.在 iOS 4 上,layoutSubviews 消息在滚动视图的超级视图(这是我的组件)上发送,但在 iOS 5 上似乎不再发送消息...

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...

查看 iOS 5 发行说明和变更日志后,我没有发现任何提及此类变更的内容.我错过了什么吗?

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?

推荐答案

在 iOS5 中,不会在 scrollView 的超级视图上调用 layoutSubviews.但它是在 iOS4 中.

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

如果您希望在 iOS5 中实现此行为,请在您的 UIScrollView 子类中执行此操作:

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]; 

这可能已更改为更有效.仅仅因为 UIScrollView 是滚动的,并不意味着它的 superview 需要自己布局.

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

这篇关于iOS 5 中的 UIScrollView layoutSubviews 行为变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆