Klemen
Klemen

Reputation: 2180

When to modify constranints so it will override storyboard setup?

The problem of mine is, that I setup the constraints in the storyboard. But then I want to adapt it before the view appears on screen.

So for example if I lay down 5 views in a line and I want to hide one of then on smaller phones, where do I put the code for this. I tried viewWillApper, but the storyboard setup loads after that method and override my setup.

I found viewDidLayoutSubviews but now Im wondering if this is the best approach. Because I think this gets called many times later but I want some method that is called only after constraints are modifyed by storybord setup. So just before the main view appears on screen.

Hope you'll guide me in the right direction.

Upvotes: 0

Views: 37

Answers (1)

Lucas Huang
Lucas Huang

Reputation: 4016

The constraint will finish setting when viewDidLoad gets called. viewDidLayoutSubviews will be called by the system in proper time or when you change you orientation.

Upvotes: 1

Related Questions