我有一个项目,该项目需要横向查看图,一旦轻按“后退”按钮,它应返回纵向以查看菜单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;
   }
}

最佳答案

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

关于ios - 在Objective C中点击“后退”按钮时如何将界面方向从横向更改为纵向,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58282180/

10-12 00:18
查看更多