【问题标题】:How to change interface orientation from landscape to portrait when back button is tapped in Objective C在Objective C中点击后退按钮时如何将界面方向从横向更改为纵向
【发布时间】:2019-10-08 07:49:24
【问题描述】:

我有这个项目需要横向查看图表,一旦点击后退按钮,它应该返回纵向查看菜单 Daily GraphCarcadian 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;
   }
}

【问题讨论】:

标签: ios objective-c screen-orientation


【解决方案1】:

你可以在viewWillDisappear 或其他地方做[[UIDevice currentDevice] setValue:@(UIDeviceOrientationPortrait) forKey:@"orientation"];。它支持 UIView 动画块

【讨论】:

  • 感谢您的回答。我试过了,当我的 iPhone 中的 AutoRotate 被锁定时它可以工作,但是当它被解锁时。它不工作。
猜你喜欢
  • 2014-08-15
  • 2023-03-17
  • 2016-05-03
  • 1970-01-01
  • 2012-08-01
  • 2020-10-13
  • 1970-01-01
  • 1970-01-01
  • 2012-07-21
相关资源
最近更新 更多