我正在研究一个项目的模块,当我得到它时,屏幕处于横向模式。我必须加载一个新视图,然后切换到纵向模式。虽然这看起来很简单,但我找不到简单的解决方案。这是我试过的:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
locationsView =[[LocationsViewController alloc] initWithNibName:@"LocationsViewController" bundle:nil];
[self.view addSubview:locationsView.view];
并没有像我需要的那样工作。它将状态栏旋转到纵向模式,但不是视图的其余部分。
有什么建议吗?
托马斯
答案 0 :(得分:1)
这样做了:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait];
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
//resize the view
self.view.bounds = CGRectMake(0.0, 0.0, 320, 460);
self.view.center = CGPointMake(240, 140);
locationsView =[[LocationsViewController alloc] initWithNibName:@"LocationsViewController" bundle:nil];
[self.view addSubview:locationsView.view];
确保在Global.h中定义degreesToRadian。