objective-c – UIScrollView每次滚动时调用layoutSubviews()

前端之家收集整理的这篇文章主要介绍了objective-c – UIScrollView每次滚动时调用layoutSubviews()前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我将UIScrollView(IPhone SDK)子类化并覆盖(void)layoutSubviews;方法.
我注意到每次滚动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.

原文链接:https://www.f2er.com/c/110726.html

猜你在找的C&C++相关文章