首先是AppDelegate,这里加载rootViewController方法要变下 :
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{ self.window = [[UIWindow alloc]initWithFrame:screenBounds];
RootViewController * mainViewController =[[RootViewController alloc] init];
rootNavigationController * navigationController = [[rootNavigationController alloc]
initWithRootViewController:mainViewController];
[window setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
在rootViewController调用的方法这三个方法就是用来控制所有的页面的横竖屏的;这三个方法是系统级的;
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{ return [self.viewControllers.lastObject supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.viewControllers.lastObjectpreferredInterfaceOrientationForPresentation]; }