ios UIView layoutSubviews调用时机
来源:互联网 发布:印度红色走廊知乎 编辑:程序博客网 时间:2024/05/22 09:48
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 the setNeedsLayout method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call the layoutIfNeeded method.
大致意思是 iOS5.1之前这个方法没有任何作用。这个方法默认功能是控制一个子view的大小和位置
凡事继承UIView的子类都都可以实现这个方法,来控制子视图。实现次方法的前提是你觉得系统布局不能满足你的要求,你可以在这个方法里面做更为精确的设置
这个方法你无需调用。如果你想要更新layout的话 可以调用这个方法:setNeedsLayout 来实现。如果不想立刻刷新layout 你可以调用layoutIfNeeded 方法
下面我们研究下这个方法调用的时机
1.init初始化的时候是不会触发的。但是调用initWiftFrame 并且参数fram不为0的时候会调用.换句话就是大小或者位置更改的时候调用。
2,添加子视图的时候会调用(即调用addsubView方法的时候)
3,修改了frame的时候调用(1,也属于此类情况)
4,UIScrollView滚动的时候会调用此方法
5,屏幕旋转的时候会调用
6,子视图修改的时候会调用父级视图的此方法
- 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区别及调用的时机
- 【Linux】使用__wrap_malloc查看内存使用
- 乐观锁和悲观锁
- 如何使div居中-简单实现
- 宋朝
- 多边形区域填充算法--扫描线填充算法(有序边表法)
- ios UIView layoutSubviews调用时机
- 实现一个固定长度的集合队列
- 利用CPrintDialog,打印文件——流程清晰
- [Android] C/C++ logcat
- 中文分词系统NLPIR(2015版)的Java接口使用学习
- 关于一些iOS开发中容易忽略的一些属性设置
- ios didMoveToSuperview
- 系统调用的用途
- Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04