Xcode/Stackview, empty labels freaks out in stack view?

╄→гoц情女王★ 提交于 2019-12-23 15:17:25

问题


hopefully an easy one here. I have some labels and text fields. Between them, I want some empty labels, which will if needed to be error texts. But when I try to stack view it all, Xcode zooms out and nothing can be seen on the viewController. Anything else I need to change for it to work?

You can see a picture of it here before I hit stack view:

The email label and text field are already in stack view, so are passwords, gentag passwords and label/button.


回答1:


This certainly appears to be a bug. I duplicated your issue. I was able to solve it by setting a height/width to each empty spacer label, prior to adding it to my stack view. This doesn't make sense because when you add an object to a stack view it loses all of the constraints it has. None the less it resolved the issue:




回答2:


Sounds like its just an auto layout issue (or lack of). Can be really messy, best to just keep playing around.

As you've already done, I would first put each label and its text field in a horizontal stack view and add constraints.

Then I'd add each of these stackviews to their individual warning labels in a vertical stackview and add constraints.

Finally I would combine all of the stackviews into one vertical stackview!



来源:https://stackoverflow.com/questions/46603285/xcode-stackview-empty-labels-freaks-out-in-stack-view

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