简体   繁体   English

xCode自动布局不适用于所有iPhone屏幕

[英]xCode autolayout not working for all iPhone screens

I'm done my app, and the last thing I'm trying to finish up is the AutoLayout, I created the autolayout with reference to an iPhone 6 screen, and it fits perfectly on it and the 6+. 我已经完成了我的应用程序,最后要完成的是自动版式,我参考iPhone 6屏幕创建了自动版式,它非常适合它和6+。 But for the 5 and 4 it becomes bunched and isn't working well. 但是对于5和4,它变得一团糟,并且运作不佳。 I've tried everything from resizing, switching modes and etc. They should all look like the first screenshot.I've added screenshots.The order is: iPhone 6, iPhone 5, iPhone 4s 我尝试了所有操作,包括调整大小,切换模式等。它们都应该看起来像第一个屏幕快照。我添加了屏幕快照。顺序为:iPhone 6,iPhone 5,iPhone 4s

Here are the constraints: 这里是约束:

On the big UIImage: Align Centre x to temperature Label Align Centre y to White Indicator Align top space to City Label Align bottom space to temperature Label 在大的UIImage上:将中心x对准温度标签将中心y对准白色指示器将顶部空间对准城市标签将底部空间对准温度标签

On Temperature Label: 在温度标签上:

Width = 150 Height = 44 Align centre x to Image View Above Align centre x to white indicator Bottom space to loading label (right underneath it) top space to imageview 宽度= 150高度= 44将中心x对准上方的图像视图将中心x对准白色指示器底部空间以加载标签(在其下方)顶部空间以imageview

All the time labels are aligned left and right to the temp labels as well as top and bottom space between weather images 所有时间标签都与温度标签以及天气图像之间的顶部和底部空间左右对齐

First small weather image: Leading to superview bottom space to superview align centre x to time label above it trailing space to uiimage on the right align bottom/top to other uiimages on the right 第一个小天气图像:导致超级视图底部空间超级视图,将中心x对齐到其上方的时间标签,尾随空间将右uiimage对齐,将底部/顶部与右侧其他uiimage对齐

second small weather image: same as above except width = 80 and no leading space to superview I've tried removing this one, but whenever i do the UIImage shrinks, and this is the only way I can keep it the same size as others 第二个小天气图像:除宽度= 80外,其他与上图相同,没有超级空间可以观看,我尝试删除此图像,但是每当UIImage缩小时,这是保持其与其他大小相同的唯一方法

third small image: same as the first, but includes leading space to superview 第三个小图片:与第一个小图片相同,但包含领导观看的空间

fourth: same as the first and includes trailing space to superview 第四:与第一个相同,并包含尾随空间以供观看

Turn Off Alarm button at the bot: Align centre x to temperature label (the big one) Top space to smaller temp labels Trailing to superview Height = 100 在机器人上关闭“警报”按钮:将中心x对准温度标签(较大的一个)将顶部空间对准较小的温度标签跟踪到超级视图高度= 100

iPhone 6 iphone 5 iPhone4的

Incase anyone else ever runs into this problem, my main issue was that I was using size classes despite the fact I was only creating an app for iPhones. 万一其他人遇到这个问题,我的主要问题是尽管我只是为iPhone创建一个应用程序,但我仍在使用尺寸类别。 So by clicking on the storyboard and clicking on any view controller and going to file inspector (first icon) I unchecked the size classes button. 因此,通过单击情节提要板并单击任何视图控制器,然后转到文件检查器(第一个图标),我取消选中大小类别按钮。 This way I could add autolayout and constraints and it would work across all iPhone screens. 这样,我可以添加自动布局和约束,并且可以在所有iPhone屏幕上使用。 Although small adjustments were required to make it work it was much easier 尽管需要进行一些小的调整才能使其正常工作,但要容易得多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM