OGeek|极客世界-中国程序员成长平台

标题: ios - 在仅纵向应用程序中以横向模式呈现 UIViewController [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:47
标题: ios - 在仅纵向应用程序中以横向模式呈现 UIViewController

我的应用只是一个肖像。我需要在横向模式下呈现 UIViewController(原因是我正在使用 Core-Plot sdk 在该 View Controller 上绘制图形,因此它需要处于横向模式)。

我尝试了以下方法,效果很好。但问题是,当我关闭横向 View Controller 时,应用无法强制进入纵向模式。

http://www.sebastianborggrewe.de/only-make-one-single-view-controller-rotate/

http://b2cloud.com.au/tutorial/forcing-uiviewcontroller-orientation/

如何在关闭横向 View Controller 后强制应用变为仅纵向模式?

这就是我展示横向 View Controller 并将其关闭的方式。

 LineChartViewController *obj = [[LineChartViewController alloc]initWithNibName"LineChartViewController" bundle:nil];

 [self.navigationController presentViewControllerbj animated:YES completion:nil];  


- (IBAction)btnDonePressedid)sender{
    [self dismissViewControllerAnimated:NO completion:nil];
}

LineChartViewController 的 XIB 处于横向模式。

简单来说,我的应用是纵向的,我想以横向模式显示 CorePlot hostView。



Best Answer-推荐答案


其实我可以通过旋转 CorePlot hostView 来解决这个问题。该解决方案对于所描述的问题并不完美,但我想把我的解决方案放在这里,因为它解决了我的问题

self.hostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc] initWithFrame:self.viewGraphBack.bounds];
self.hostView.allowPinchScaling = YES;
[self.viewGraphBack addSubview:self.hostView];

CGAffineTransform transform =
CGAffineTransformMakeRotation(DegreesToRadians(90));

viewGraphBack.transform = transform;

viewGraphBack.frame = CGRectMake(-285, 0, 568, 320);

[self.view addSubview:viewGraphBack];

关于ios - 在仅纵向应用程序中以横向模式呈现 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25056664/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4