我的应用程序只是一个肖像 . 我需要在Landscape模式下呈现一个UIViewController(原因是我使用Core-Plot sdk在该viewcontroller上绘制图形,因此它需要处于横向模式) .
我尝试了以下方法,它工作正常 . 但问题是,当我解除横向视图控制器时,app无法强制进入纵向模式 .
http://www.sebastianborggrewe.de/only-make-one-single-view-controller-rotate/
http://b2cloud.com.au/tutorial/forcing-uiviewcontroller-orientation/
如何在关闭横向视图控制器后强制应用程序变为 portrait only 模式?
这就是我如何呈现景观视图控制器并解除它 .
LineChartViewController *obj = [[LineChartViewController alloc]initWithNibName:@"LineChartViewController" bundle:nil];
[self.navigationController presentViewController:obj animated:YES completion:nil];
- (IBAction)btnDonePressed:(id)sender{
[self dismissViewControllerAnimated:NO completion:nil];
}
LineChartViewController的XIB处于横向模式 .
In simple words, My app is portrait only, and I wanted to show CorePlot hostView in landscape mode.
4 回答
在您的项目中写下此类别
在您需要Landscape的viewcontroller中
实际上我可以通过旋转CorePlot hostView来解决问题 . 对于所描述的问题,解决方案并不完美,但我想把解决方案放在这里,因为它解决了我的问题
这种解决方法适用于我(临时推送假模型视图控制器),在引入新方向的其他视图控制器被调用后被调用:
如果在
UIInterfaceOrientationPortrait
模式和当前viewcontroller中的父视图控件应该在UIInterfaceOrientationLandscapeLeft
或UIInterfaceOrientationLandscapeRight
中,那么您可以使用设备方向更改委托和viewdidload
中的一些代码在ViewDidLoad中
在ViewController中实现
shouldAutorotateToInterfaceOrientation
委托像这样 . 确保必须从目标设置签入横向模式 .