支持iOS 4.3到iOS 6.0

时间:2022-04-15 11:15:10

I already have the base code that supports ios 4.3 to ios 5. Now I would also like to support ios 6.0. The present base code has modal views, hard coded CGRect's, and rotation is different for each view. So I would like to know whether we can support ios 4.3 to ios 6.0 with the same base code, by just tweaking some changes, or do we need to create a complete new target?

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

Like we cannot use auto layout of ios 6.0 if I want to support previous versions as it will lead to a crash.

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

3 个解决方案

#1


4  

Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this

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

Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

isn't called for iOS 6. It is replaced by the methods,

没有为iOS 6调用它。它被方法取代,

- (NSUInteger)supportedInterfaceOrientations

- (BOOL)shouldAutorotate

You would need all the iOS versions on devices and then test each and every aspect of your app.

您需要在设备上使用所有iOS版本,然后测试应用的每个方面。

#2


1  

Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.

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

#3


1  

Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.

是的,它非常好,可以使用xcode 4.5支持ios 4.3到ios 6.0。

And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in @Mayur J's answer.

而对于ios 6中的方向必须做一些工作,就像必须以不同的方式放置一些代码,如@Mayur J的答案中所述。

Or all you can do is just add categories for the required controller's like UINavigationController, UIPopoverViewController, UIImagePickerViewController, etc to return the supported orientation in ios 6.0 like below

或者你所能做的只是为所需的控制器添加类别,如UINavigationController,UIPopoverViewController,UIImagePickerViewController等,以返回ios 6.0中支持的方向,如下所示

.h file

#import <UIKit/UIKit.h>

@interface UIPopoverController (UIPopoverController_Orientation)

-(NSUInteger) supportedInterfaceOrientations;

@end

.m file

#import "UIPopoverController+UIPopoverController_Orientation.h"

@implementation UIPopoverController (UIPopoverController_Orientation)

-(NSUInteger) supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}
@end

Here I use UIInterfaceOrientationMaskLandscape as I only supports landscape orientations ie restrict my app to only landscape mode.

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

Hope this will help you.

希望这会帮助你。

Happy Coding :)

快乐编码:)

#1


4  

Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this

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

Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

isn't called for iOS 6. It is replaced by the methods,

没有为iOS 6调用它。它被方法取代,

- (NSUInteger)supportedInterfaceOrientations

- (BOOL)shouldAutorotate

You would need all the iOS versions on devices and then test each and every aspect of your app.

您需要在设备上使用所有iOS版本,然后测试应用的每个方面。

#2


1  

Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.

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

#3


1  

Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.

是的,它非常好,可以使用xcode 4.5支持ios 4.3到ios 6.0。

And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in @Mayur J's answer.

而对于ios 6中的方向必须做一些工作,就像必须以不同的方式放置一些代码,如@Mayur J的答案中所述。

Or all you can do is just add categories for the required controller's like UINavigationController, UIPopoverViewController, UIImagePickerViewController, etc to return the supported orientation in ios 6.0 like below

或者你所能做的只是为所需的控制器添加类别,如UINavigationController,UIPopoverViewController,UIImagePickerViewController等,以返回ios 6.0中支持的方向,如下所示

.h file

#import <UIKit/UIKit.h>

@interface UIPopoverController (UIPopoverController_Orientation)

-(NSUInteger) supportedInterfaceOrientations;

@end

.m file

#import "UIPopoverController+UIPopoverController_Orientation.h"

@implementation UIPopoverController (UIPopoverController_Orientation)

-(NSUInteger) supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}
@end

Here I use UIInterfaceOrientationMaskLandscape as I only supports landscape orientations ie restrict my app to only landscape mode.

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

Hope this will help you.

希望这会帮助你。

Happy Coding :)

快乐编码:)