在物镜C中轻按后退按钮时如何将界面方向从横向更改为纵向

问题描述 投票:0回答:1

我有这个项目,必须具有横向才能查看图形,并且一旦轻按后退按钮,它应该返回到纵向以查看菜单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个回答
0
投票
您可以在[[UIDevice currentDevice] setValue:@(UIDeviceOrientationPortrait) forKey:@"orientation"];或其他位置执行viewWillDisappear。它支持UIView动画块
© www.soinside.com 2019 - 2024. All rights reserved.