iOS 8 / XCode 6 autolayout constraints applied after view appears

前端 未结 3 672
谎友^
谎友^ 2020-12-29 04:20

I have a project that was working just fine with XCode 5 and iOS 7, but when I recently downloaded XCode 6, I noticed some weird behavior with autolayout.

I have a s

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 04:35

    Where is your code that is making changes to your constraints?

    If you're keeping it in viewWillAppear: you will have that problem. I found that viewDidLayoutSubviews works well for iOS8 but not always for iOS7 backwards.

    Eventually, if you cant use viewDidLayoutSubviews, what I'd suggest is hide the container view in viewDidLoad and unhide it in viewWillAppear, only after the constraints have been applied. It gets you a small extra delay when loading the screen but the constraints change gets transparent to the user.

提交回复
热议问题