我是一个全新的iOS开发新手,我面临着Xcode9 AutoLayout的一个主要问题和障碍(我已经半死不活了:)。
该应用程序从后端获取一些博客帖子,并以卡片视图显示它们。我使用iPhone 8布局作为主要起点,所有的故事板配置都保留为默认配置。
就像我说的,我几乎没有任何带有故事板和iOS设计的XP。
打开故事板时,当我转到助理编辑器并查看其他感兴趣的屏幕尺寸(加号和4英寸)时,应用程序UI看起来完全关闭了,即使我在所有元素上都使用了约束。
当我在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
发布于 2017-11-03 03:58:36
尝试删除imageView上的固定宽度
<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>https://stackoverflow.com/questions/47071600
复制相似问题