为什么叫viewdidlayoutsubviews多次? [英] Why viewdidlayoutsubviews call multiple times?

查看:1752
本文介绍了为什么叫viewdidlayoutsubviews多次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对雨燕的iOS开发通用应用程序,使用自动布局和仅支持肖像。

I'm developing iOS Universal App on Swift,using auto layout and support only portrait.

我发现的UIViewController#viewdidlayoutsubviews 多次调用。相反, viewDidLoad中仅在启动MyApp的的UIViewController调用一次。

I found UIViewController#viewdidlayoutsubviews called multiple times. Instead, viewDidLoad ONLY call once on starting up MyApp's UIViewController.

为什么viewdidlayoutsubviews多次调用?每个UIView的约束(UIButtons,UITextFields等)会按顺序执行?

Why viewdidlayoutsubviews call multiple times? Constraints on each UIView(UIButtons,UITextFields etc..) will perform in order?

任何信息将AP preciated。

Any Information will be appreciated.

推荐答案

的loadView 只能称为一种:当视图需要加载

LoadView is only called one: when the view needs to be loaded.

LayoutSubviews ,但是,每次运行循环调用一次上有过任何视图 setNeedsLayout setNeedsDisplayInRect 调用它 - 这包括每当一个子视图已被添加到视图,滚动,缩放,等

LayoutSubviews, however, is called once per run loop on any view that has had setNeedsLayout or setNeedsDisplayInRect called on it - this includes whenever a subview has been added to the view, scrolling, resizing, etc.

请参阅链接了解更多信息。它使用Objective-C的,但信息仍然有效。

See this link for more information. It uses Objective-C, but the information still holds.

这篇关于为什么叫viewdidlayoutsubviews多次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆