-1

I created a project in Swift. I added view controller file and one XIB using right click on the project - > Add Files to projectname -> Empty (xib) file.

After adding the xib file, i removed the view and added View Controller. Under the View controller , i have added few button. But i am not able set the constraints.But if i add the View object instead of View Controller, i am able to set the constraints. I don't understand why the xib constraints are disabled for View controller. Attached the screen shot

enter image description here

cto platform
  • 191
  • 3
  • 12
  • Why would you put a view controller in a xib? If you want to design a view controller, use a storyboard. Your Layout pop up menu in the screen shot means “no constraints” by the way. – matt Apr 01 '20 at 08:24
  • you mean to say we should not use xib to create UIViewController. What is the reason for this? – cto platform Apr 01 '20 at 09:01

1 Answers1

3

Layout is set to Translates Mask Into Constraints, meaning that IB is gonna generate the constraints for you automatically. Set it to Automatic and it'll work.

enter image description here

Bence Pattogato
  • 3,752
  • 22
  • 30