iOS UIView layoutSubviews调用时机
来源:互联网 发布:决对争锋网络剧百度云 编辑:程序博客网 时间:2024/06/07 09:57
iOS 官方文章中对UIView的layoutSubviews 介绍如下:
The default implementation of this method does nothing on iOS 5.1 and earlier. Otherwise, the default implementation uses any constraints you have set to determine the size and position of any subviews.
Subclasses can override this method as needed to perform more precise layout of their subviews. You should override this method only if the autoresizing and constraint-based behaviors of the subviews do not offer the behavior you want. You can use your implementation to set the frame rectangles of your subviews directly.
You should not call this method directly. If you want to force a layout update, call thesetNeedsLayout method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call thelayoutIfNeeded method.
大致意思是 iOS5.1之前这个方法没有任何作用。这个方法默认功能是控制一个子view的大小和位置
凡事继承UIView的子类都都可以实现这个方法,来控制子视图。实现次方法的前提是你觉得系统布局不能满足你的要求,你可以在这个方法里面做更为精确的设置
这个方法你无需调用。如果你想要更新layout的话 可以调用这个方法:setNeedsLayout 来实现。如果不想立刻刷新layout 你可以调用layoutIfNeeded 方法
下面我们研究下这个方法调用的时机
1.init初始化的时候是不会触发的。但是调用initWiftFrame 并且参数fram不为0的时候会调用.换句话就是大小或者位置更改的时候调用。
2,添加子视图的时候会调用(即调用addsubView方法的时候)
3,修改了frame的时候调用(1,也属于此类情况)
4,UIScrollView滚动的时候会调用此方法
5,屏幕旋转的时候会调用
6,子视图修改的时候会调用父级视图的此方法
基本归纳了这么多,大家可以继续研究分享
苹果开发群 :414319235 欢迎加入 欢迎讨论问题
- iOS UIView layoutSubviews调用时机
- ios UIView layoutSubviews调用时机
- layoutSubviews调用时机
- layoutSubviews的调用时机
- layoutSubviews的调用时机
- LayoutSubviews的调用时机
- layoutSubViews方法调用时机
- - (void)layoutSubviews 调用时机
- UIView layoutSubviews何时调用
- iOS UIView的layoutSubviews和drawRect方法何时调用
- iOS UIView 的 layoutSubviews 方法
- iOS layoutSubviews的调用
- ios 什么时候调用layoutSubviews
- UIView的layoutSubviews什么时候被调用
- ios UIView的layoutSubviews和drawRect
- iOS中layoutSubviews的调用
- ios笔记layoutSubviews 什么时候调用
- layoutSubviews、setNeedsLayout、setNeedsDisplay、drawRect区别及调用的时机
- 基础教程
- Unity3D研究院之利用缓存池解决Instantiate慢的问题
- Flex中添加大量组件时内存占用问题
- 适配iOS9遇到的一些问题_Scheme白名单_ Bitcode及解决办法
- 黑马程序员-Java基础学习第四天总结
- iOS UIView layoutSubviews调用时机
- iOS 一个控件无法显示出来的原因
- (50道编程题)兔子生兔子 php
- HttpServletResponse,HttpServletRequest详解
- 指针与数组(二)
- ACM训练计划
- socket关闭
- 配置环境变量
- 12-EMM Procedure 2. Detach