iOS layoutSubviews 什么时候会被调用
2015-04-17 10:31
393 查看
原文:When does layoutSubviews get called?
It’s important to optimize any UIView layoutSubviews method you create, as it can be frequently called, and has the potential for creating recursion (triggering a setNeedsLayout from layoutSubviews can create a loop that will grossly affect your apps performance). Layout subviews is called once per run loop on any view that has had setNeedsLayout or setNeedsDisplayWithRect: called on it. So in addition to any time you manually call these methods, it can be useful to know when the UI framework calls setNeedsLayout/setNeedsDisplay as this will trigger layoutSubviews.
。init does not cause layoutSubviews to be called (duh)
初始化时不会调用layoutSubviews
。addSubview
causes layoutSubviews to be called on the view being added, the view
it’s being added to (target view), and all the subviews of the target
view
[view addSubview:subView]会使view,subView和view的所有子view都调用layoutSubviews
。setFrame
intelligently calls layoutSubviews on the view having it’s frame set
only if the size parameter of the frame is different
setFrame,只有当改变frame的frame.size并且改变前后的size大小不一样时会调用layoutSubviews,改变frame.origin不会调用layoutSubviews
。scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and it’s superview
滑动UIScrollView会使该scrollview和它的父视图调用layoutSubviews
。rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)
旋转设备只会使父视图调用layoutSubviews
。removeFromSuperview – layoutSubviews is called on superview only
removeFromSuperview只会是父视图调用layoutSubviews
建议大家看原文,上面只是摘录
It’s important to optimize any UIView layoutSubviews method you create, as it can be frequently called, and has the potential for creating recursion (triggering a setNeedsLayout from layoutSubviews can create a loop that will grossly affect your apps performance). Layout subviews is called once per run loop on any view that has had setNeedsLayout or setNeedsDisplayWithRect: called on it. So in addition to any time you manually call these methods, it can be useful to know when the UI framework calls setNeedsLayout/setNeedsDisplay as this will trigger layoutSubviews.
。init does not cause layoutSubviews to be called (duh)
初始化时不会调用layoutSubviews
。addSubview
causes layoutSubviews to be called on the view being added, the view
it’s being added to (target view), and all the subviews of the target
view
[view addSubview:subView]会使view,subView和view的所有子view都调用layoutSubviews
。setFrame
intelligently calls layoutSubviews on the view having it’s frame set
only if the size parameter of the frame is different
setFrame,只有当改变frame的frame.size并且改变前后的size大小不一样时会调用layoutSubviews,改变frame.origin不会调用layoutSubviews
。scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and it’s superview
滑动UIScrollView会使该scrollview和它的父视图调用layoutSubviews
。rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)
旋转设备只会使父视图调用layoutSubviews
。removeFromSuperview – layoutSubviews is called on superview only
removeFromSuperview只会是父视图调用layoutSubviews
建议大家看原文,上面只是摘录
相关文章推荐
- ios笔记layoutSubviews 什么时候调用
- ios layoutsubView 何时被调用
- iOS开发笔记--什么时候调用layoutSubviews
- iOS巅峰之layoutSubviews在什么时候调用
- iOS开发笔记--什么时候调用layoutSubviews
- iOS开发笔记--什么时候调用layoutSubviews
- iOS开发笔记--什么时候调用layoutSubviews
- ios 什么时候调用layoutSubviews
- layoutSubviews 什么时候被调用
- iOS开发笔记--什么时候调用layoutSubviews
- iOS开发笔记--什么时候调用layoutSubviews
- iOS开发笔记--什么时候调用layoutSubviews
- iOS: initwithframe什么时候会被调用?
- layoutSubviews在什么时候被调用
- iOS setNeedsLayout&layoutSubviews 视图重绘总结
- -(void)layoutSubviews什么时候触发调用
- iOS UIView中 - (void)drawRect:(CGRect)rect;和-(void)ViewLayoutSubViews;的调用时机
- layoutsubviews什么时候会被调用
- layoutSubviews在什么时候调用
- iOS viewDidLoad 什么时候调用