Behavior changes for updateViewConstraints in iOS 8

喜你入骨 提交于 2020-01-01 10:41:28

问题


I notice some small graphical glitches while testing one of my app under iOS 8: some UIViews elements are not in the right place, others have not the right size.

In a first step, I use storyboard, Auto-Layout and constraints. Then I programmatically tune constraints to perfectly suits devices' screen size, using updateViewConstraints.

Perfect on iOS 7 but with some glitches on iOS8 as on following picture: ./Users/dominiquevial/Documents/Informatique/Dev/Novae Marathon/_log/captures/iOS8 - iPhone 6/pause.png

After investigation I found the problem: updateViewConstraints is not called. I don't understand why, maybe due to some optimizations...

Correcting this problem is easy :

  1. use viewWillLayoutSubviews in place of updateViewConstraints
  2. or add call to setNeedsUpdateConstraints in viewWillAppear

Which way is the best one ?


回答1:


Depends if the user can cause the views to enter an invalid state after the view appears, if so the first option. If this is not possible the second.

The less work your app has to do the better.



来源:https://stackoverflow.com/questions/25948001/behavior-changes-for-updateviewconstraints-in-ios-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!