【问题标题】:iOS6 landscape app with only one controller multioriented popViewController issueiOS6横向应用程序只有一个控制器多向popViewController问题
【发布时间】:2013-04-11 22:10:46
【问题描述】:

我的这个设置在我的大多数视图控制器中只支持横向

我的应用委托有这段代码:

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
 {
     NSUInteger orientations = UIInterfaceOrientationMaskLandscape;
    if (self.window.rootViewController) {
        UIViewController * pressented = [[((UINavigationController *)self.window.rootViewController) viewControllers] lastObject];
        orientations =[pressented supportedInterfaceOrientations];
    }
    return orientations;
 }

在大多数视图控制器中:

-(NSUInteger)supportedInterfaceOrientations
 {
    return UIInterfaceOrientationMaskLandscape;
 }

当我推动这个控制器(我想旋转的那个)时,我的问题出现了:

-(NSUInteger)supportedInterfaceOrientations
 {
    return UIInterfaceOrientationMaskALL;
 }

它完美地旋转,但是当我弹出视图控制器(点击导航栏的后退按钮)且方向为纵向时,呈现的视图控制器也将其方向设置为纵向。

如何使呈现的视图控制器保持锁定在横向上,或者在弹出之前强制有问题的控制器旋转回横向。

【问题讨论】:

    标签: objective-c ios6 orientation


    【解决方案1】:

    将此添加到您的纵向视图控制器:

    -(void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
        UIViewController* dummyController = [[UIViewController alloc] init];
        [self presentViewController:dummyController animated:NO completion:^{
            [self dismissViewControllerAnimated:NO completion:nil];
        }];
    }
    

    我知道这是一个 hack,但它确实有效。谁知道更好的解决方案?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-24
      • 1970-01-01
      • 2012-12-19
      • 1970-01-01
      • 2012-09-11
      • 1970-01-01
      相关资源
      最近更新 更多