我正在使用iPad。我希望我的应用只能在lanscape模式下修复。我的应用程序包含一个拆分视图控制器和上面的拆分视图控制器我放置了登录屏幕。
用户提供必要的用户名和密码后,应删除登录视图,以便打开拆分视图控制器。它运作良好。但我希望登录屏幕设置为横向模式。我尝试了很多方法,但我的问题仍未解决。我在一个plist中放置了一个带有值lanscape的UIOrientaion键。但没用。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//UIInterfaceOrientationLandscapeLeft;
// Overriden to allow any orientation.
// return UIInterfaceOrientationIsLandscape(interfaceOrientation);
return YES;
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
我也试过这种方式但没有结果。
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
在viewdidload中也是这样,
通过这种方式,我可以在横向模式下设置应用程序,但视图不会旋转到横向。登录视图固定在potrait模式。
在nib文件中,如果我修复了lanscape中的视图,拆分视图,rootviewcontroller出现在e侧,并且在splitviewcontroller的detailviewcontroller中,这个登录屏幕也会在potrait模式下打开.....
任何帮助将不胜感激 提前致谢
答案 0 :(得分:0)
我找到了解决问题的方法。这就是编码:
[ViewController *newDetailViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[window addSubview:newDetailViewController.view];
[window addSubview:anotherViewController.view];
[window bringSubviewToFront:newDetailViewController.view];
通过这种方式我们应该将子视图添加到委托。之后通过视图控制器中的自动旋转方法修复景观中的视图..它