Autolayout crash when applying transform: Assertion failure in -[layoutSublayersOfLayer:]

前端 未结 2 1396
傲寒
傲寒 2020-12-19 10:59

I have a custom view that display a UILabel in the bottom right corner. The view is setup in a method called from both initWithCoder: and initWithFrame:

相关标签:
2条回答
  • 2020-12-19 11:23

    In iOS7 you need to do this on viewDidAppear. It will also work for iOS8. If you dont want to see the delayed element change on screen, hide your super view on viewDidLoad and unhide it on viewDidAppear, right after you apply your changes.

    0 讨论(0)
  • 2020-12-19 11:26

    I had this issue in iOS7 (but not iOS8) from putting constraint adjustments in viewWillLayoutSubviews. Moving constraint adjustment to viewWillAppear fixed it for me.

    0 讨论(0)
提交回复
热议问题