简体   繁体   English

管理对iOS6和iOS7的支持的最佳方法是什么?

[英]What is the best way to manage support for both iOS6 and iOS7?

I always have an app requirement to support both iOS6 and iOS7 . 我一直有一个应用程序要求同时支持iOS6iOS7 But because of iOS6 support, I can't use some feature of iOS7 . 但是由于iOS6支持,我无法使用iOS7某些功能。

For example, I have to do UIView bounce animation, in iOS6 I have to do it with CAKeyframeAnimation or UIView animation, but iOS7 has UIKit dynamics which provide me UIDynamicAnimator class and I can do with it. 例如,我必须做UIView弹跳动画,在iOS6我必须用CAKeyframeAnimationUIView动画iOS7 ,但是iOS7具有UIKit dynamics ,可以为我提供UIDynamicAnimator类,我可以使用它。

So should I always use older methods like CAKeyframeAnimation or UIView animation because it supports both iOS6 and iOS7 or write both by checking iOS version? 所以,我就应该总是使用旧的方法,如CAKeyframeAnimationUIView动画,因为它同时支持iOS6iOS7或检查都写iOS版本?

Ruthlessly strip things from the iOS 6 version that require ios7 features to work, particularly if they are cosmetic things like bouncing animations. 无情地从iOS 6版本中剥离了需要ios7功能才能正常工作的内容,尤其是如果它们是诸如弹跳动画之类的精美内容时。

When challenged about this, tell your client they can spend 80% of their dev budget supporting an ever-shrinking pool of unconcerned users, or they can get real. 当对此有挑战时,告诉您的客户他们可以将80%的开发预算用于支持不断缩小的无关用户群,否则他们可以成为现实。 API compatibility is only one headache between 6 and 7. The layout issues are far harder. API兼容性只是6到7之间的一个令人头疼的问题。布局问题要困难得多。 Any new app being written today needs a really, really good reason to support 6, particularly with 8 just round the corner. 今天编写的任何新应用都需要一个非常非常好的理由来支持6,尤其是8即将到来的时候。

I believe the best way is to check iOS version and implement both variants of code. 我相信最好的方法是检查iOS版本并实现两种代码变体。

Yes, maybe, it's quite a lot of work but in majority of cases newest features provided in new iOS releases are more flexible and simple to understand/integrate. 是的,也许这是很多工作,但是在大多数情况下,新iOS版本中提供的最新功能更加灵活,易于理解/集成。 In most cases they are also more plain in support. 在大多数情况下,他们也很支持。 They are supported by Apple with more care and there is a small possibility of their deprecation. Apple会更加谨慎地支持它们,并且弃用的可能性很小。

You can use Foundation runtime variable NSFoundationVersionNumber and NSFoundationVersionNumber_iOS_6_1 macros to divide your code: 您可以使用Foundation运行时变量NSFoundationVersionNumberNSFoundationVersionNumber_iOS_6_1宏来划分代码:

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
    // write iOS 7+ code here 
} 
else {
    // write iOS 6.1- code here 
}

Note, sometimes some recent released API can be quite raw. 请注意,有时最近发布的一些API可能还很原始。 In such cases you should take a decision individually whether you really need the migration immediately. 在这种情况下,您应该单独决定是否真的需要立即进行迁移。

You can use class API to check for availability of classes. 您可以使用class API来检查类的可用性。

if ([UIPrintInteractionController class]) {
   // Create an instance of the class and use it.
}
else {
   // The print interaction controller is not available.
}

For more information see link below Advanced App Tricks 有关更多信息,请参见高级应用程序技巧下面的链接。

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

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