1

I'm using XCode 4 to develop an application that can be run on iPhone 3.1.3. On iOS4 Simulator works fine, but on my device, I get an error.

This is AppDelegate code where I get the error.

@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; } 

I get the following error in 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' 

Any advice?

1 Answer 1

5

As rootViewController property appeared in UIWindow only in iOS4.0 you can't use it for older platforms. For iOS 3.x you'll have to add controller's view to UIWindow manually and you code will look similar to:

if ([self.window respondsToSelector:@selector(setRootViewController:)]) self.window.rootViewController = self.viewController; else [self.window addSubview:self.viewController.view]; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.