博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
layoutSubviews在何时调用
阅读量:6953 次
发布时间:2019-06-27

本文共 1555 字,大约阅读时间需要 5 分钟。

原文:

 

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

 

转载于:https://www.cnblogs.com/damao2012/p/3375278.html

你可能感兴趣的文章
从零实现一个RPC框架系列文章(一):思路篇
查看>>
记录微信小程序一些小细节
查看>>
致校招生的若干面试建议
查看>>
Canvas 都坐下,基本操作
查看>>
华为测试大牛Python+Django接口自动化怎么写的?
查看>>
SpringCloud 广告系统实战(三) - 通用模块的开发
查看>>
新手学写多语言(国际化)
查看>>
你必须掌握在Flutter中添加资源文件
查看>>
go语言与c语言的相互调用
查看>>
Git Personal Manual
查看>>
小菜菜3月前端面试记录汇总---持续更新
查看>>
前端之路:紧跟潮流,docker简单应用
查看>>
PHP Session
查看>>
Django1-配置MySQL数据库
查看>>
小强面试记
查看>>
如何隐藏或删除Windows 10任务栏图标
查看>>
创建自定义模板
查看>>
Qtum量子链周报(3月18日-3月24日)
查看>>
你真的知道如何使用Vue.set吗
查看>>
couchbase介绍与实践(一)
查看>>