In viewDidLoad changing active on constraints from storyboard has no effect

Originator:jpmhouston
Number:rdar://27379661 Date Originated:15-Jul-2016 02:12 PM
Status:Open Resolved:
Product:iOS Product Version:
Classification: Reproducible:
 
Area:
UIKit

Summary:
In a storyboard with custom viewcontroller, views with some constraints, strong outlets to some of the constraints intending for view controller to activate & deactivate at runtime, when viewDidLoad is called the outlets have been set to their constraints, but they are not fully "loaded". Adding the constraints to their views seems to be deferred until roughly the time of viewWillLayoutSubviews, and any change to a constraint's "active" property seems to be ignored until then.

Steps to Reproduce:
1. nib has constraint1 Installed checked, constraint2 Installed not checked
2. in viewDidLoad do constraint1.active=false; constraint2.active=true
3. in viewDidAppear, look at states of constraint1 & constraint2

Expected Results:
In viewDidAppear, constraint1.active is false, constraint2.active is true

Actual Results:
In viewDidAppear, constraint1.active is true, constraint2.active is false.

In my app, I'm in fact seeing several calls to viewWillLayoutSubviews, after the first constraint1.active is still false, constraint2.active is still true, but after the second constraint1.active is true, constraint2.active is false.

Version:
iOS 9.3.2, Xcode 7.3.1

Notes:


Configuration:
iPhone 6+

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!