Why is viewDidLayoutSubviews called multiple times?

后端 未结 2 1286
日久生厌
日久生厌 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:29

    The best thing to do and this has served me well - is to get in to the habit of adding a log or print statement to methods of which you are unsure

    I use this ->

    print("Hello From \(NSStringFromSelector(#function))")
    

    or this if inside a View Subclass

    Swift.print("Hello From \(NSStringFromSelector(#function))")
    

    It will print the method when it is being called.

提交回复
热议问题