• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在仅纵向应用程序中以横向模式呈现 UIViewController

[复制链接]
菜鸟教程小白 发表于 2022-12-13 08:47:00 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我的应用只是一个肖像。我需要在横向模式下呈现 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap