在 Xcode 6.3.1 中弹出一个弹出窗口,“无法自动更新约束”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30150823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:07:29  来源:igfitidea点击:

A popup, "Failed to automatically update constraints" pops up in Xcode 6.3.1

xcodeautolayout

提问by zeeawan

When I added a couple of controls in my viewcontroller in storyboard and click Resolve Auto Layout Issues -> Reset to Suggested Constraints. The following popup appears and I cannot perform auto layout constraints.

当我在情节提要的视图控制器中添加几个控件并单击 Resolve Auto Layout Issues -> Reset to Suggested Constraints 时。出现以下弹出窗口,我无法执行自动布局约束。

enter image description here

在此处输入图片说明

Though, when I remove the Prototype Cell (which has a couple of labels and an imageview) from my tableview then auto layout works fine. Any thoughts?

但是,当我从我的 tableview 中删除 Prototype Cell(它有几个标签和一个 imageview)时,自动布局工作正常。有什么想法吗?

Edited:And manually adding constraints to individual elements work fine as well. After manually setting the image view inside prototype cell, the auto layout has started working fine without popping up that popup. So, maybe, sometime, it is hard for auto layout to figure out all these constraints itself.

编辑:手动向单个元素添加约束也可以正常工作。在原型单元内手动设置图像视图后,自动布局开始正常工作而不会弹出该弹出窗口。所以,也许在某个时候,自动布局很难自己弄清楚所有这些约束。

回答by adrienMarsden.jpeg

Try clearing constraints before resetting them, this has worked for me before.enter image description here

在重置它们之前尝试清除约束,这以前对我有用。在此处输入图片说明

回答by mjrehder

I had the same problem when using prototype cells in a UITableView and some other views in a UIViewController.

在 UITableView 中使用原型单元格和在 UIViewController 中使用其他一些视图时,我遇到了同样的问题。

My solution was to select all the elements in the prototype cell and see if these had red or orange markers (constraint conflicts/problems). These elements I cleared the constraints for and afterwards I had no problem telling the entire view to "Reset to Suggested Constraints".

我的解决方案是选择原型单元格中的所有元素,看看它们是否有红色或橙色标记(约束冲突/问题)。我清除了这些元素的约束,之后我可以毫无问题地告诉整个视图“重置为建议的约束”。

Obviously, Interface Builder has a problem resetting embedded table content constraints.

显然,Interface Builder 在重置嵌入的表格内容约束时有问题。

回答by Avijit Nagare

Following Solution work for me.

以下解决方案对我有用。

Actually initially i used Free-from storyboard of size 600 into 900 that time i was getting this error. so i deleted that storyboard and again drag and drop element and make connections, then i solved issue.

实际上最初我使用了大小为 600 到 900 的 Free-from 故事板,当时我遇到了这个错误。所以我删除了那个故事板并再次拖放元素并建立连接,然后我解决了问题。

回答by Narasimha Nallamsetty

I have faced same problem with Xcode 6. In my MainViewController I have a tableview with custom TableviewCell. In Interface builder itself I have taken taken 2 labels on tableview cell.

我在 Xcode 6 中遇到了同样的问题。在我的 MainViewController 中,我有一个带有自定义 TableviewCell 的 tableview。在界面生成器本身中,我在 tableview 单元格上取了 2 个标签。

When I try to add constraints it gives me error. I did remove prototype cell in tableview and worked with nib with customCell. Be careful while working with custom tableViewCell.

当我尝试添加约束时,它给了我错误。我确实删除了 tableview 中的原型单元格,并使用带有 customCell 的 nib 工作。使用自定义 tableViewCell 时要小心。

Let me know if you need any additional information.

如果您需要任何其他信息,请告诉我。

回答by Durul Dalkanat

Actually . If you import different storyboard from another Xcode project. This is not possible to avoid problem. My personal advice is create a new UIViewcontroller or stroyboard. And step by step add items. But. I did not do this.

实际上 。如果您从另一个 Xcode 项目导入不同的故事板。这是不可能避免的问题。我个人的建议是创建一个新的 UIViewcontroller 或 stroyboard。并逐步添加项目。但。我没有这样做。

I lived three times. In fact When I saw this message. I was configuring tableview or UITableviewcell. At the end of the story I have fixed my problem. But There is no gold key for issue. I will explain as much as possible.

我住了三回。其实当我看到这条消息的时候。我正在配置 tableview 或 UITableviewcell。在故事的结尾,我解决了我的问题。但是没有发行的金钥匙。我会尽可能多地解释。

  1. for All Views in View Controller select Clear Constraints
  2. If you are using tableview or collection view. please delete.
  3. I assume. there are label, button and scrollview on the project. Please add missing constraints. If you leave problem again. You need to delete any of them.
  4. for All Views in View Controller Reset to Suggested constraints. If you don't leave problem again. PERFECT. If there is a reverse situation

  5. for All Views in Second View Controller select Clear Constraints

  6. delete any of item. Select add missing constraints again.
  1. 对于视图控制器中的所有视图,选择清除约束
  2. 如果您使用的是 tableview 或 collection view。请删除。
  3. 我假设。项目上有标签、按钮和滚动视图。请添加缺少的约束。如果你再次留下问题。您需要删除其中任何一个。
  4. 对于视图控制器中的所有视图重置为建议的约束。如果你不再留下问题。完美的。如果有相反的情况

  5. 对于第二个视图控制器中的所有视图,选择清除约束

  6. 删除任何项目。再次选择添加缺少的约束。

Continue to try the third and fourth steps. Until you find the faulty objects.

继续尝试第三步和第四步。直到找到有问题的对象。

I'll try to help you if you submit your project.

如果您提交项目,我会尽力帮助您。

Good luck .

祝你好运 。

回答by Shefali Soni

I had same issue last evening, After many try and error i found that it was just a corrupt ViewController. I created a new ViewController2 with the same aspects, then applied constraints to the ViewController2, and it worked! Still not sure why exactly the other one had issues.

昨晚我遇到了同样的问题,经过多次尝试和错误,我发现它只是一个损坏的 ViewController。我创建了一个具有相同方面的新 ViewController2,然后对 ViewController2 应用了约束,它起作用了!仍然不确定为什么另一个有问题。

If it helps to anybody else :)

如果它对其他人有帮助:)

[Edit Moderator: i have removed answer from other posts]

[编辑版主:我已经从其他帖子中删除了答案]

回答by Nefedova Oxana

I had some problem with Xcode 7. I solved it very simple. I cleared constraints -

我在 Xcode 7 上遇到了一些问题。我很简单地解决了它。我清除了约束-

Reset to Suggested Constrains

重置为建议的约束

, then applied -

,然后应用 -

Add Missing Constrains.

添加缺少的约束。

This has worked for me.

这对我有用。

enter image description here

在此处输入图片说明