i did a simple navigati开发者_如何学Pythononbased app. it works on iphone very well, but it doesnt work on ipad 3.2 simulator and device.
in applicationdidfinish event;
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
[self.navigationController pushViewController:viewController animated:NO];
self.window.rootViewController = self.navigationController;
[viewController release];
it says for this line:
self.window.rootViewController = self.navigationController;
[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x4c22dd0
but it works on ipad 4.2 and over.
how can i solve it for ipad 3.2?
UIWindow did not have a rootViewController property in iOS < 4.0. Therefore, you will need to check the version (google it) and then either set the rootViewController, or add the navigationController's view
as a subview to the window as below, based on what version your user is running.:
[self.window addSubview:self.navigationController.view];
quick edit: to check if you can use the rootViewController property, you can check if [self.window respondsToSelector:@selector(setRootViewController)]
returns TRUE or FALSE.
The correct way is (don't forget ":"!):
if ( [self.window respondsToSelector:@selector(setRootViewController:)] )
self.window.rootViewController = self.tabBarController;
else
[self.window addSubview: self.tabBarController.view];
精彩评论