iOS 4.3 SDK部署到iPhone 3.1.3错误

时间:2011-07-07 13:15:18

标签: ios ios4

我正在使用XCode 4开发可在iPhone 3.1.3上运行的应用程序。在iOS4上模拟器工作正常,但在我的设备上,我收到错误。

这是我收到错误的AppDelegate代码。

@implementation VoConstructorAppDelegate


@synthesize window=_window;

@synthesize viewController=_viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

我在self.window.rootViewController = self.viewController;中收到以下错误:

2011-07-07 15:10:20.997 VoConstructor[159:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0
2011-07-07 15:10:21.053 VoConstructor[159:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0'

有什么建议吗?

1 个答案:

答案 0 :(得分:5)

由于rootViewController属性仅在iOS4.0中出现在UIWindow中,因此无法将其用于旧版平台。对于iOS 3.x,您必须手动将控制器的视图添加到UIWindow,您的代码将类似于:

if ([self.window respondsToSelector:@selector(setRootViewController:)])
   self.window.rootViewController = self.viewController;
else
   [self.window addSubview:self.viewController.view];