ios - 在Objective C中点击后退按钮时如何将界面方向从横向更改为纵向
问题描述
我有这个项目需要横向查看图表,一旦点击后退按钮,它应该返回纵向查看菜单Daily Graph
和Carcadian Graph
. 当用户点击Daily Graph
它以横向显示图形时,趋势用户将手持手机以横向视图,当back
点击按钮返回菜单时,纵向运行平稳,但当用户点击Carcadian Graph
它以横向显示图形时,趋势,用户将在横向视图中握住他的手机,当back
点击按钮返回时menuVC
,它只会保持横向,它应该是纵向的。我该如何解决它,需要一些帮助,因为我是 Objective C 的新手。谢谢
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
if (self.orientation == UIInterfaceOrientationLandscapeRight)
{
UINavigationController *navController =(UINavigationController*)[self.tabBarController selectedViewController];
UIViewController *dispViewController = navController.viewControllers.lastObject;
if ([dispViewController.nibName isEqualToString:@"dailyGraph_vc"] == YES || [dispViewController.nibName isEqualToString:@"circadianGraph_vc"] == YES)
{
return 0;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
else
{
return 0;
}
}
解决方案
你可以[[UIDevice currentDevice] setValue:@(UIDeviceOrientationPortrait) forKey:@"orientation"];
在上面viewWillDisappear
或其他地方做。它支持 UIView 动画块
推荐阅读
- java - 在 Eclipse(Indigo)中构建声纳时出错 无法执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar
- laravel - 对要使用的关系类型感到困惑
- c - 在C中更改子进程中的当前工作目录
- jquery - Django,访问从 JQuery AJAX 发送的 html 表单字段值
- python - 在虚拟环境中运行 Python 时忽略 PATH
- ubuntu - 如何设置密码以便我可以连接到 Google Cloud 实例上的 FTP
- postgresql - 将 postgresql 模式传递给 alembic 迁移
- javascript - JavaScript 事件未触发(与 websockets 同步连接)
- javascript - 为什么我不能打印重叠矩形的 id?
- sql - 如何将两个查询结果合二为一,我有不同的列名