Auto layout + size classes issue in swift

2019-08-11 12:27发布

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?

1条回答
Explosion°爆炸
2楼-- · 2019-08-11 12:42

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/

查看更多
登录 后发表回答