支持iOS8和iOS7的设计应用程序 [英] Design app that supports both iOS8 and iOS7

查看:115
本文介绍了支持iOS8和iOS7的设计应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想设计一个主详细信息应用程序,通用应用程序的Xcode6主 - 详细项目模板包括UISplitViewController和splitViewController是iOS8中的新功能。我也想支持iOS7的应用程序。

Suppose I want to design a master detail application, Xcode6 master-detail project template for universal app includes UISplitViewController and splitViewController is new in iOS8. I want to support app for iOS7 also.

一般


  1. 什么是使用支持iOS8和iOS7的Xcode6
    故事板设计通用应用程序的最佳方式?

  2. 为不同的操作系统版本使用单独的故事板是否更好?

  3. 我们应该遵循哪些最佳做法来使应用与这两种操作系统兼容?


推荐答案

创建此类应用程序的最佳方式可能取决于您的应用程序需要做什么。根据所需的任何特殊行为,某些方法会比其他方式更好。

The 'best way' to create such an app will likely depend on what exactly your app needs to be able to do. Some ways will be better than others depending on any special behavior needed.

但是在Xcode 6中使用单个通用故事板绝对可以使用大小类并且仍然是目标iOS 7,包括iPhone和iPad,使用 UISplitViewController 。我已经成功地做到了这一点。它确实需要做很多工作才能确保它在iOS 7和8上运行正常并且看起来一致。在执行各种新的自适应segue时你必须要小心,因为这是iOS 7和8之间的巨大差异例如,检测你有弹出窗口的时候需要为两个不同的操作系统做一些工作,处理展开segue需要一些特殊处理等。这需要大量的测试。专注于测试iPhone 6 Plus的时间 - 在横向上,它将在屏幕上显示主控和细节,但您可以控制它。

But it is definitely possible to use a single Universal storyboard in Xcode 6 that uses Size Classes and still target iOS 7, both iPhone and iPad, using UISplitViewController. I have successfully done just that. It did take a lot of work to ensure it worked properly and looked consistent on iOS 7 and 8. You have to be a little careful when it comes to performing the various new adaptive segues, as that is a huge difference between iOS 7 and 8. For example, detecting when you have a popover is going to require some work for the two different OSes, handling unwind segues will require some special handling, etc. It will require a lot of testing. Dedicate time to testing the iPhone 6 Plus - in landscape it will show both the master and detail on screen, but you can have control over that.

在完成体验之后,我会很多而不是实现一个故事板,而不是两个故事板,每个操作系统一个,并且绝对不会为每个操作系统创建一个故事板,然后为每个设备类型创建一个故事板。

After going through that experience, I would much rather implement a single storyboard as opposed to two storyboards, one for each OS, and definitely stay away from creating a storyboard for each OS and then one for each device type.

您需要阅读 SDK兼容性指南,了解如何检测API可用性。如果您实现了iOS 7上不存在的API,则应用程序将崩溃,因此如果该应用程序运行的操作系统存在该功能,则只需运行该代码。例如,您可能希望使用新的 UIBlurEffect API,但在iOS 7中不存在。了解弃用的含义,并了解已发生的变化。 iOS 8将大有帮助。例如,不推荐使用旋转API以支持Size Class特征集合,但这些在iOS 7上不可用,因此您需要继续使用已弃用的旋转API。

You'll want to read up on the SDK Compatibility Guide to learn how to detect API availability. If you implement an API that doesn't exist on iOS 7 the app will crash, so you need to only run that code if that function exists for the OS the app is running on. For example, you may want to utilize the new UIBlurEffect API, but that doesn't exist on iOS 7. Gain an understanding of what deprecation means, and knowing what has changed in iOS 8 will greatly help. For example, the rotation APIs are deprecated in favor of Size Class trait collections, but those aren't available on iOS 7 so you'll need to continue to use the deprecated rotation API.

另请参阅今年的 WWDC视频。他们有几个视频讨论新的自适应segue和通用故事板。请注意,这些故事板向后兼容iOS 7,但有些大小类在iOS 7上不可用。请参阅这个问题以及我提供的答案以获取更多信息。前几年的WWDC视频还讨论了如何支持多个操作系统,渐进增强等。

Also check out some WWDC videos from this year. They have a couple videos that discuss the new adaptive segues and Universal storyboards. Note that these storyboards ARE backwards compatible with iOS 7, but there are some size classes that aren't made available on iOS 7. See this question and the answer I provided for more information. WWDC videos from previous years also discuss how one can support multiple OSes, progressive enhancement, etc.

当然,当您遇到问题/问题时,Stack Overflow是一个很好的资源。我在过去几个月发布的很多问题与此主题完全相关,如何修改 UISplitViewController 行为,使用单个故事板获得对两个操作系统的支持您可能希望仔细阅读这些内容,以了解在以相同方式开发应用时可能遇到的问题。

And of course when you have questions/problems Stack Overflow is a great resource. A lot of the questions I've posted in the past few months are related to this topic exactly, how to modify UISplitViewController behavior, obtain support for both OSes, using a single storyboard and the new adaptive segues, etc. You may wish to read through those to get an idea of what you can expect to run into when developing an app in the same fashion.

这篇关于支持iOS8和iOS7的设计应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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