Why is viewDidLayoutSubviews called multiple times?

后端 未结 2 1287
日久生厌
日久生厌 2020-12-13 19:36

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

I found UIViewController.viewDidLayoutSubviews called multipl

2条回答
  •  孤城傲影
    2020-12-13 20:14

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

    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.

提交回复
热议问题