使用导航控制器将视图复制到项目 - 用于“图像视图”的框架在运行时会有所不同 [英] Copied a View to a project with Navigation Controller - Frame for "Image View" will be different at run time

查看:119
本文介绍了使用导航控制器将视图复制到项目 - 用于“图像视图”的框架在运行时会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于有经验的Xcode 5界面构建器用户来说可能是一个简单的问题,但很难在Google上找到答案:



我有并将详细信息视图复制到其中(此处)如果有人有更多改进建议:



解决方案

选择 UIImageView 然后单击 [ - o - ] 图标,然后选择重置为建议的约束菜单项。
模拟指标部分在运行时没有任何作用,只有我们才能弄清楚编译前布局的样子。



还有一种(更好的)方法,但是您必须分析 UIImageView 具有哪些约束并相应地更改它们以进行新布局(添加了导航栏)。您可以尝试在这里发布带有这些约束的屏幕截图,这样我们就可以帮助您弄清楚发生了什么。转到右侧面板中的尺寸检查器,然后向我们显示约束部分。



更新



您的约束强制 UIImageView 与下面的标签具有相同的水平对齐并具有相同的宽度。另外,您对最上面的标签和导航栏中的固定垂直空间有限制, UIImageView 的宽度取决于导航栏和标签之间的可用空间。我认为这是当前布局(没有滚动)的好方法,因为一切都适合3.5英寸和4英寸显示屏的屏幕。如果您想要不同的行为,请在评论中告诉我。


Probably a simple question for experienced Xcode 5 interface builder users, but it is difficult to find the answer on Google:

I have an app for iPhone, which doesn't use a navigation controller (here fullscreen):

The view scene on the very right side has an image view and 5 labels underneath it - to display user details:

Then I have created another iPhone app and copied that "details" view to it (here fullscreen):

And now a warning is shown by Xcode 5.0.2:

Frame for "Image View" will be different at run time.

Is it because some space on the top of the view will be occupied by the navigation bar?

And how to fix it please?

I've tried clicking the [-o-] icon, but instead of resolving my layout issue it has messed the whole layout (the labels jumped to the left).

Also I've tried setting checkboxes on the right side in the Xcode Attributes Inspector, but haven't be able to find any good combination there (and I am not sure what "inferred" means in Xcode context).

UPDATE:

Ossir's suggestion has worked for me, thank you.

I'm posting a new screenshot (here fullscreen) in case anybody have more improvement suggestions:

解决方案

Select the UIImageView and click [-o-] icon, then choose Reset To Suggested Constraints menu item. Simulated metrics section does nothing in the runtime, it only us to figure out how layout will look like before compiling.

Also there is one more (better) approach, but you have to analyse what constraints UIImageView has and change them accordingly for new layout (with added nav bar). You can try to post screenshot with those constraints here, so we can help you to figure out what happened. Go to Size Inspector in right panel and show us Constraints section.

UPDATE

Your constraints force UIImageView to have the same horizontal align as labels below have and the same width. Plus you have constraints for fixed vertical space from the topmost label and navigation bar, width of UIImageView depends on available space between nav bar and labels. I think it's good solution for current layout (without scrolling), because everything will fit into the screen for both 3.5" and 4" inch displays. In case you want different behaviour let me know in a comments.

这篇关于使用导航控制器将视图复制到项目 - 用于“图像视图”的框架在运行时会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆