
纵向和横向的布局完全不同,因此使用UIautoResizingMask无法解决.
我尝试使用layoutSubvIEw方法,但我检测到布局子视图被调用很多(来自UIScrollVIEw).
如何减少layoutSubvIEw调用以优化代码,或者我应该在旋转设备时自己调用它.
谢谢.
解决方法 layoutSubvIEws被子UIScrollVIEw调用的事实是非常不幸的,但有一个(丑陋的)解决方法:@interface MyClass : UIVIEw { BOol reallyNeedsLayout_;}@end@implementation MyClass- (voID)setNeedsLayout{ [super setNeedLayout]; reallyNeedsLayout_ = YES;}- (voID)setFrame:(CGRect)rect{ [super setFrame:rect]; reallyNeedsLayout_ = YES;}- (voID)layoutSubvIEws{ if (!reallyNeedsLayout_) return; reallyNeedsLayout_ = NO; // Do layouting.}@end 不是最好的解决方案,但似乎工作得相当好.
总结以上是内存溢出为你收集整理的iphone – 何时在iOS中使用layoutSubview全部内容,希望文章能够帮你解决iphone – 何时在iOS中使用layoutSubview所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)