简体   繁体   English

Xcode不了解这些约束,并且无法按我想要的方式工作

[英]Xcode Dont understand these constraints and its not working the way I want it

So I can seem to get these constraints to work properly. 因此,我似乎可以使这些constraints正常工作。 I did something on one of my ViewControllers and it works perfect. 我在其中一个ViewControllers上做了一些操作,效果很好。 I just don't remember how I did it. 我只是不记得我是怎么做到的。

So when I update constraints on the new ViewController , then I get warnings stating Frame for "object" will be different at run time. 因此,当我在新的ViewController上更新constraints时,我得到警告,指出“对象”的帧在运行时将有所不同。 Then yellow dashed outlines of the selected object appear lower in the ViewController. 然后,所选对象的黄色虚线轮廓在ViewController中显示在下方。 Then if I click Editor -> Update Frames , it shifts everything down to where the yellow dashed boxes are. 然后,如果click Editor -> Update Frames ,它将所有内容向下移动到黄色虚线框所在的位置。 I don't wan't this to happen. 我不希望这发生。 I want my objects in the ViewController to go where I place them. 我希望将ViewController对象放到放置它们的位置。

Why does it place the yellow dashed box lower than where I actually have it placed? 为什么将黄色虚线框放置在比我实际放置的位置低的位置?

This is with one item selected. 这是选中的一项。 See how the yellow dashed box is lower than I want it. 查看黄色虚线框如何低于我想要的水平。 Now when I was setting this up I have the UIScrollView to fit the whole canvas. 现在,当我进行此设置时,我可以使用UIScrollView来适应整个画布。 That is how the other ViewController is set up. 这就是设置另一个ViewController方式。

在此处输入图片说明

Ok so update. 好的,请更新。 I got to playing around and I found that the navigation bar had a lot to do with that. 我到处玩耍,发现导航栏与此有关。 I deleted the segue that lead into the ViewController and set on the constraints where I wanted everything. 我删除了导致进入ViewControllersegue ,并设置了我想要的一切约束。 Then I re-added the segue and everything was where I wanted it. 然后我重新添加了segue ,一切都在我想要的位置。 I don't know if this is the correct way or the best way to achieve this. 我不知道这是正确的方法还是实现此目标的最佳方法。

Also I got to playing around more and found that I didn't have to delete the segue I could just put everything behind the navigation bar, add constraints then update the frame. 另外,我还玩了更多,发现我不必删除segue ,只需将所有内容放在导航栏后面,添加约束,然后更新框架即可。 Again I am not sure if this the proper way to do it but it did work the way I needed it to work. 同样,我不确定这是否是正确的方法,但是它确实按照我需要的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM