Auto layout + size classes issue in swift

纵然是瞬间 提交于 2019-12-11 04:49:52

问题


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:


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/



来源:https://stackoverflow.com/questions/27099015/auto-layout-size-classes-issue-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!