我将UIScrollView(IPhone SDK)子类化并覆盖(void)layoutSubviews;方法.
我注意到每次滚动scrollView时都会调用此方法.
我注意到每次滚动scrollView时都会调用此方法.
这是正确的行为还是我的代码中有错误?如果是默认行为,这不是性能杀手吗?
此致
海因里希
解决方法
这是正确的行为,它应该用于获取子视图的自定义布局.我已经多次使用它并且没有任何性能问题因为添加了数百个项目.
关于该主题的documentation的截止:
Subclasses can also be containers for other views. In this case,just override the designated initializer,initWithFrame:,to create a view hierarchy. If you want to programmatically force the layout of subviews before drawing,send setNeedsLayout to the view. Then when layoutIfNeeded is invoked,the layoutSubviews method is invoked just before displaying. Subclasses should override layoutSubviews to perform any custom arrangement of subviews.