iOS 7:“标签 - 标签”的错位视图框架在运行时会有所不同
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18758154/
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
iOS 7: Misplaced View Frame for "Label - Label" will be different at run time
提问by AJ112
I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to be compatible with iOS 7.
我刚刚在 iOS 6 上完成了一个应用程序,并在一周前购买了一个开发者帐户,所以没有太多时间玩 iOS 7 SDK。刚刚下载了 Golden Master 版本并尝试升级我的应用程序以与 iOS 7 兼容。
I received a lot of warnings saying
我收到了很多警告说
Misplaced View Frame for "Label - Label" will be different at run time.
“标签 - 标签”的错位视图框架在运行时会有所不同。
and I am unable to run the program. The project contains tableview and its is parsing and displaying XML feed from an RSS.
我无法运行该程序。该项目包含 tableview,它正在解析和显示来自 RSS 的 XML 提要。
How to fix this issue?
如何解决这个问题?
采纳答案by Tarek Hallak
I had the same issue and I get below response form Apple:
我遇到了同样的问题,我得到了以下 Apple 的回复:
You need to update the constraints to match the frames of these views.
您需要更新约束以匹配这些视图的框架。
I did the following:
我做了以下事情:
Editor -> Resolve Auto-Layout Issues -> Clear all constraints in ** view controller
编辑器 -> 解决自动布局问题 -> 清除 ** 视图控制器中的所有约束
then I reordered my objects again in the view.
然后我再次在视图中重新排序我的对象。
PS: Try Enrico's solution first.
PS:先试试Enrico的解决方案。
回答by Enrico Susatyo
The accepted answer will fixthe problem, but that's not a good solution because it'll remove all your constraints. If you have spent hours on the constraints then don't do that.
接受的答案将解决问题,但这不是一个好的解决方案,因为它会消除您的所有限制。如果您在约束上花费了数小时,则不要这样做。
If you click the triangle next to the warning you can get the explanation of what is misplaced. Then you can just move the frame to where it's supposed to be. For example:
如果您单击警告旁边的三角形,您可以获得错位内容的说明。然后您可以将框架移动到它应该在的位置。例如:
In this case I just moved my Text View's y position to 94 and the warning will go away. This is because one of my constraints will force the view to be somewhere else when the app is running, but the position is different than where it currently is in the storyboard.
在这种情况下,我只是将文本视图的 y 位置移动到 94,警告就会消失。这是因为当应用程序运行时,我的约束之一将强制视图位于其他位置,但该位置与它当前在故事板中的位置不同。
Another way to move the frame to the right position is to click on the warning next to the View Controller name in your storyboard, and then click on the yellow warning sign, and click update frame.
将框架移动到正确位置的另一种方法是单击情节提要中视图控制器名称旁边的警告,然后单击黄色警告标志,然后单击更新框架。
These two methods are not destructive and will not remove your constraints. If anything it'll show that you may need to do minor readjustments in your constraints.
这两种方法都不是破坏性的,也不会消除您的约束。如果有的话,它会表明您可能需要对您的约束进行细微的调整。
回答by Sandy
I had the same issue what you need to is , update the constraints or update the frame.
On storyboard you have a small tool bar as shown in below image.
我遇到了同样的问题,您需要更新约束或更新框架。在故事板上,您有一个小工具栏,如下图所示。
Please see the meaning:-
请看意思:-
You can either choose "Update Frames" or "Update Constraints" and Use "Reset to Suggested Constraints". This will resolve the issue regarding misplaced View. Don't drag and drop views to make adjustments to layout. Edit the applicable constraints instead. Please , let me know if you not clear.
您可以选择“更新框架”或“更新约束”并使用“重置为建议的约束”。这将解决有关错位视图的问题。不要拖放视图来调整布局。改为编辑适用的约束。请让我知道如果你不清楚。
回答by sivi
回答by clearlight
None of the answers work in all cases. As of recent version of Xcode, using a UISearchBar, enabling scoping field enabled in IB makes the search field appear double height (but doesn't show a the scoping bar beneath it). Whether or not you add a height constraint (of any height) to the search field, you'll get the warning that it is a misplaced view that will be 88 H at runtime but is 44 H in IB. Updating the frames (any or all frames) doesn't resolve it. Seems like a bug in IB.
没有一个答案在所有情况下都有效。从最新版本的 Xcode 开始,使用 UISearchBar,启用在 IB 中启用的范围字段会使搜索字段显示双倍高度(但不会在其下方显示范围栏)。无论您是否向搜索字段添加高度约束(任何高度),您都会收到警告,指出这是一个错误放置的视图,在运行时为 88 H,但在 IB 中为 44 H。更新框架(任何或所有框架)并不能解决它。似乎是 IB 中的一个错误。