What's exactly viewDidLayoutSubviews?

后端 未结 2 1209
独厮守ぢ
独厮守ぢ 2020-12-29 14:05

I was reading the description of viewDidLayoutSubviews of UIViewController:

Called to notify the view controller that its vi

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 14:44

    viewDidLayoutSubviews will be called when

    When the bounds change for a view controller's view, the view adjusts the positions of its subviews and then the system calls this method.

    For example you have set constraints of your view then you want to update the frame for your subview in viewDidLoad(), which will not make any impact as in viewDidLoad() your constraints are not properly set, they will get properly set when viewDidLayoutSubviews get called, now you want to update the frames of your subview, then you can do that in this method as this method get called only after all the constraints of your view are properly set.

提交回复
热议问题