Dominoo
Dominoo

Reputation: 108

Autolayout mixing code and interface builder

I would like to use Autolayout in my project

Ideally I would like to have xib where I "pre-arrange" my views approx possition and height and all outlets and actions to the master.

Then I would like in - viewDidLoad addConstraints to all views so they re-arrange

Is this even good solution? How I should proceed set xib to use autolayout ? Should I remove all constraints before I set my own ?

thanks for any suggestions

Upvotes: 1

Views: 402

Answers (1)

sha
sha

Reputation: 17860

I would suggest to do the following:

  • Setup all necessary constraints in IB.
  • Create outlets for constraints you need to change dynamically (if that's what you're trying to do)
  • In your viewDidLoad method access these outlets and change the values

This way you get best parts of both worlds. You get UI for originally setting up all layout and then you can adjust it in run-time.

Upvotes: 2

Related Questions