支持iOS 4.3到iOS 6.0

我已经有了支持ios 4.3到ios 5的基本代码。现在我也想支持ios 6.0。 目前的基本代码具有modal views ,硬编码的CGRect's ,并且每个视图的旋转是不同的。 所以我想知道我们是否可以用相同的基本代码支持ios 4.3到ios 6.0,只需调整一些更改,还是需要创build一个完整的新目标?

就像我们不能使用ios 6.0的自动布局,如果我想支持以前的版本,因为它会导致崩溃。

是的,我们可以通过将部署目标设置为iOS 4.3来实现。 但是,那么为什么你需要支持iOS 5.0,85%-90%的设备在iOS 5.0+上。 看到这个

另外,当你设置对iOS 4.3甚至iOS 5.1.1的支持时,你将不得不处理多个事情。 例如,Orientation的方法,

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

不是为iOS 6调用。它被replace的方法,

 - (NSUInteger)supportedInterfaceOrientations - (BOOL)shouldAutorotate 

您将需要设备上的所有iOS版本,然后testing应用程序的每个方面。

使用Xcode 4.5,使用一个代码库构buildiOS 4.3-6.0应用程序是完全有效的,但是一如既往,关键是使用给定的操作系统版本在真实的iDevices上进行testing。

是的,它是完全正常的,可以使用xcode 4.5来支持ios 4.3到ios 6.0。

而对于ios 6中的方向必须做一些工作,就像不得不像@Mayur J的回答所写的那样放置一些代码

或者你所能做的只是添加所需的控制器的类别,像UINavigationControllerUIPopoverViewControllerUIImagePickerViewController等,以返回支持的方向在iOS 6.0中像下面

.h文件

 #import <UIKit/UIKit.h> @interface UIPopoverController (UIPopoverController_Orientation) -(NSUInteger) supportedInterfaceOrientations; @end 

.m文件

 #import "UIPopoverController+UIPopoverController_Orientation.h" @implementation UIPopoverController (UIPopoverController_Orientation) -(NSUInteger) supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } @end 

在这里,我使用UIInterfaceOrientationMaskLandscape因为我只支持横向方向,即限制我的应用程序只横向模式。

希望这会帮助你。

快乐编码:)