我的程序仅使用横向模式。早些时候我使用的是xcode 4.5,但现在它不能正常工作了,我使用的是xcode 5.模拟器,它可以旋转四面。
我只需要左右风景。
在我的app委托中,我把
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;//|UIInterfaceOrientationLandscapeRight;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft );
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate{
if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft ||[[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else{
return NO;
}
}
在我的每个viewcontroller中,我把
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
每个故事板viewconrtoller和导航视图控制器我都这样设置。
我该如何解决这个问题
答案 0 :(得分:0)
确保在appDelegate中将最顶层控制器添加为rootViewController,如下所示
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
navigation=[[UINavigationController alloc]initWithRootViewController:self.viewController];
[self.window setRootViewController:navigation];
}