Behavioral changes for updateViewConstraints in iOS 8

I noticed some slight graphical crashes when testing one of my applications under iOS 8: some UIViews elements are not in the right place, others are not the right size.

In the first step, I use storyboard, auto-layout, and restrictions. Then I programmatically adjust the limits to fit the device screen size perfectly using updateViewConstraints .

Ideal for iOS 7, but with some glitches on iOS8, as in the following figure:. / Users / dominiquevial ​​/ Documents / Informatique / Dev / Novae Marathon / _log / capture / iOS8 - iPhone 6 / pause.png

After researching, I found a problem: updateViewConstraints not being called. I do not understand why, perhaps due to some optimizations ...

Fixing this problem is easy:

  • use viewWillLayoutSubviews instead of updateViewConstraints
  • or add a call to setNeedsUpdateConstraints in viewWillAppear

Which is the best way?

+5
source share
1 answer

It depends if the user can force the view to enter an invalid state after the view appears, if this is the first option. If this is not possible, the second.

The less your application should do, the better.

+1
source

Source: https://habr.com/ru/post/1203032/


All Articles