在横向模式下呈现导航控制器不适用于ios 6.0 [英] Presenting Navigation Controller in Landscape mode is not working ios 6.0

查看:89
本文介绍了在横向模式下呈现导航控制器不适用于ios 6.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码。

 SomeController *analyticsViewController = [[SomeController alloc] init];

 MTNavigaionLandscapeViewController *analyticsNavigaionObject =  [[MTNavigaionLandscapeViewController alloc] initWithRootViewController:analyticsViewController];

 [analyticsNavigaionObject setNavigationBarHidden:YES];

 if ([self respondsToSelector:@selector(presentModalViewController:animated:completion:)]) {
      [self presentViewController:analyticsNavigaionObject animated:YES completion:nil];
  } else {
          [self presentModalViewController:analyticsNavigaionObject animated:YES];
  }
  [analyticsViewController release];
  [analyticsNavigaionObject release];

以下是SomeController.m支持的方向

And here are the supported orientations in SomeController.m

- (NSUInteger)supportedInterfaceOrientations
{
 return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeRight;
}

支持MTNavigaionLandscapeViewController(UINavigationController的子类)的方向

And supported orientations in MTNavigaionLandscapeViewController(subclass of UINavigationController)

- (NSUInteger)supportedInterfaceOrientations
{
 return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
 return UIInterfaceOrientationLandscapeRight;
}

最后,如果我只提供SomeController,它工作正常..我的问题是当我提出Navigationcontroller然后出现问题。请帮助我

And finally, If i present only SomeController, it works fine.. My problem is when i present Navigationcontroller then the problem occurs. Please help me

推荐答案

在您将要呈现的ViewController中写下这些方法:

- (BOOL)shouldAutorotate
{
    AppDelegate *mainDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
    mainDelegate.shouldRotate = YES;
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

在你的AppDelegate.m中粘贴

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if(self.shouldRotate)
    {
        self.shouldRotate = NO;
        return UIInterfaceOrientationMaskLandscapeRight;
    }
    return UIInterfaceOrientationMaskPortrait;
}

在AppDelegate.h中粘贴

@property (assign, nonatomic) BOOL shouldRotate;

在ViewWillAppear中的presentsViewController中粘贴:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

这篇关于在横向模式下呈现导航控制器不适用于ios 6.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆