Clement Prem Clement Prem -4 years ago 189
Swift Question

Auto layout + size classes issue in swift

enter image description here

In the above view, viewB is a subview of viewA created using an xib and the constrains also added in the xib. viewB has constrains top, bottom, leading & trailing relative to its superview. The file owner is swift view controller. viewB is connected with the file owner

@IBOutlet weak var viewB: UIView!


But when I run the project in iPAD running iOS 8 the viewB is not visible? (in the iPhone it is visible)
I tried to access its frame in viewdidLoad & viewDidAppear, it is (0.0,0.0,0.0,0.0)

This is the only swift view controller in my project, all the other views & VC are in objc.

Is it a bug in swift or am I trying to do something wrong?

Answer Source

The issue is resolved. It was related to size classes in the XIB. One constraint was added to Cw & Rh sizes. If anyone come across this issue, check the xib's layout constrains twice :)

A good reference : http://adoptioncurve.net/archives/2014/08/working-with-size-classes-in-interface-builder/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download