简体   繁体   English

iPhone 6/6 +上的自适应UI与旧型号

[英]Adaptive UI on iPhone 6/6+ versus older models

In my application I have mostly table-view based view controllers which work and look just fine when running the app on all the iPhone models that my app supports (app is iOS 8+ thus iPhone 4S onwards). 在我的应用程序中,我主要使用基于表视图的视图控制器,当在我的应用程序支持的所有iPhone型号上运行该应用程序时,它们都可以正常工作,并且看起来很好(应用程序为iOS 8+,因此从iPhone 4S起)。

I also have a play view for some audio content with the album art, elapsed/total time labels, progress bar, etc. 我还有一个播放视图,其中包含专辑封面,经过/总时间标签,进度条等音频内容。

For this view I wasn't using any constraints so, obviously, it doesn't appear correctly on the bigger phones. 对于此视图,我没有使用任何约束,因此,显然,它在较大的手机上无法正确显示。

I've followed the last year WWDC videos where they have introduced the adaptive UI and the new size classes and I've noticed that all the examples they give reffer to using the same UI on iPhone and iPad and it's clear to me how to achieve this using size classes. 我关注了去年的WWDC视频,他们介绍了自适应UI和新的尺寸类别,并且我注意到,他们给出的所有示例都涉及在iPhone和iPad上使用相同的UI,并且我很清楚如何实现这使用大小类。 But because the iPhone 6 and 6 Plus were released only later, I couldn't find any relevant documentation on how to make my UI look right on the bigger iPhones using the new size classes concept. 但是由于iPhone 6和6 Plus只是在以后才发布,所以我找不到任何相关文档来说明如何使用新的大小类概念使UI在较大的iPhone上正确显示。 In particular, I can't seem to find a way of differentiating between the iPhone models using just the size classes. 特别是,我似乎找不到仅使用大小类来区分iPhone型号的方法。

At this point in time, I can see two solutions: 此时,我可以看到两种解决方案:

  • make 4 xib files (I am still using xibs, no storyboards) one for each device type. 为每种设备类型制作4个xib文件(我仍在使用xib,没有情节提要)。 Detect at runtime on what device I'm running and use the correct xib. 在运行时检测我正在运行的设备,并使用正确的xib。

  • make only one xib file. 只制作一个xib文件。 Use constraints and create outlets for each constraint in code. 使用约束并为代码中的每个约束创建出口。 Detect at runtime on what device I'm running and change the constraint value accordingly. 在运行时检测我正在运行的设备,并相应地更改约束值。

In the second case I only have one xib but I still have to detect the device at runtime and do some work that is device specific. 在第二种情况下,我只有一个xib,但是我仍然必须在运行时检测设备并做一些特定于设备的工作。

Obviously I don't like either of these two because they don't seem clean to me. 显然,我不喜欢这两个中的任何一个,因为它们对我而言似乎并不干净。 Ideally I would like to have one xib and no changes dependent on the device I'm running on. 理想情况下,我希望有一个xib,并且没有更改,这取决于我正在运行的设备。

Any other ideas? 还有其他想法吗? How did you solve this issue in your apps? 您如何在应用程序中解决此问题?

Thanks in advance! 提前致谢!

In my apps, I uncheck "use size class", "use autolayout" And for each object in my interfaces file, I set the autoresizing mask. 在我的应用程序中,我取消选中“使用尺寸类别”,“使用自动布局”,然后为我的interfaces文件中的每个对象设置自动调整大小掩码。

An exemple for a tableview. 表格检视的范例。

在此处输入图片说明

for example : if you don't want that your tableview change its height with the height of the parent view, remove the vertical arrow by clicking on it. 例如:如果您不希望TableView随父视图的高度更改其高度,请单击它以除去垂直箭头。

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

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