首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS应用程序中的AutoLayout问题。故事板、SImulation和实际设备之间的主要区别

iOS应用程序中的AutoLayout问题。故事板、SImulation和实际设备之间的主要区别
EN

Stack Overflow用户
提问于 2017-11-02 17:20:58
回答 1查看 134关注 0票数 0

我是一个全新的iOS开发新手,我面临着Xcode9 AutoLayout的一个主要问题和障碍(我已经半死不活了:)。

该应用程序从后端获取一些博客帖子,并以卡片视图显示它们。我使用iPhone 8布局作为主要起点,所有的故事板配置都保留为默认配置。

就像我说的,我几乎没有任何带有故事板和iOS设计的XP。

打开故事板时,当我转到助理编辑器并查看其他感兴趣的屏幕尺寸(加号和4英寸)时,应用程序UI看起来完全关闭了,即使我在所有元素上都使用了约束。

This is what I see in Xcode 9

当我在iPhone +或5S上运行模拟时,事情开始看起来好一点:

This is iPhone 5S in simulation, notice the upper right corner...

As expected, on the Plus size things look off. Just as in the Storyboards preview.

But surprise! On an actual PLUS device thins look rather well!

正如我所说的,我对UI布局约束是如何工作的有基本的了解,但我很惊讶这个问题是如此难以解决。我知道来自这个社区的任何人都不可能为我解决这个问题,我非常愿意学习。我只是真的不知道为了解决这个问题,我需要研究和实现AutoLayout系统的哪一部分。简而言之,我不知道从哪里开始我的研究,也不知道如何处理这个问题。

非常感谢您的帮助!

你可以在这里找到一个样例项目:http://www.filehosting.org/file/details/705218/DemoApp.zip

EN

回答 1

Stack Overflow用户

发布于 2017-11-03 03:58:36

尝试删除imageView上的固定宽度

代码语言:javascript
复制
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" image="PostSampleImage0.jpg" translatesAutoresizingMaskIntoConstraints="NO" id="NB1-TR-fXa">
    <rect key="frame" x="0.0" y="0.0" width="333" height="192"/>
    <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
    <constraints>
        <constraint firstAttribute="width" secondItem="NB1-TR-fXa" secondAttribute="height" multiplier="359:248" constant="55.064516129032256" id="BW1-h7-QoS"/>
    </constraints>
</imageView>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47071600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档