iOS 6方向问题 [英] iOS 6 orientation issues

查看:159
本文介绍了iOS 6方向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序通常是一个肖像应用程序,只显示一个UIViewController的横向视图。它在新的iOS 6发布之前一直正常工作。

I have an application which normally is a portrait app and only show landscape view for one UIViewController. It works fine until the new iOS 6 is released.

我真的不明白iOS 6中的方向是如何工作的。所以我写了一个测试应用程序。这是我做的:

I really don't understand how orientation works in iOS 6. So I wrote a testing app. Here is what I did:


  • 设置应用程序的方向以支持所有方向。


  • 我正在使用故事板。 rootViewController嵌入在UINavigationController中,它是纵向的。


  • rootViewController中的代码:

  • The code in rootViewController:

- (NSUInteger)supportedInterfaceOrientations

-(NSUInteger)supportedInterfaceOrientations

{

返回UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;

return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;

}


  • 当我点击打开栏按钮时,我将推送另一个(SecondViewController)视图控制器,它应该处于横向模式:

  • When I clicked the Open bar button, I'll push another (SecondViewController) view controller which supposed to be in landscape mode:

- (NSUInteger) supportedInterfaceOrientations
{
返回UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }

虽然正确调用此方法,但第二个视图控制器始终处于纵向模式。

Although this method is called correctly, the second view controller is always also in portrait mode.

有人可以给我一些建议吗?谢谢

Can anybody give me some suggestions? Thanks

推荐答案

这是我的解决方案:

在第二个视图控制器中viewDidLoad:

In second view controller's viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIViewController *viewController = [[UIViewController alloc] init];
    [self presentViewController:viewController animated:NO completion:^{
        [viewController dismissViewControllerAnimated:NO completion:nil];
    }];
}

这将强制第二个视图旋转到横向,这解决了我的问题。它适用于iOS 5和6。

This will force the second view to rotate to landscape orientation which solved my problem. And it works for iOS 5 and 6.

这篇关于iOS 6方向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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