游戏中心仅在i OS 6中登录 [英] Game center login lock in landscape only in i OS 6

查看:99
本文介绍了游戏中心仅在i OS 6中登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载游戏中心时,其默认方向为纵向。
为了在横向模式下锁定它,添加了一个类别。

When Game center is loaded its default orientation is portrait. In order to lock it in landscape mode, added a category.

@implementation GKMatchmakerViewController (LandscapeOnly)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate {
    return NO;
}
@end

在iOS 6以下工作正常。但是在iOS6中它显示错误。

It is working fine in below iOS 6 .But in iOS6 it shows an error.

由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES '

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

请解释一个解决方案。

推荐答案

最后我避免了按照Apple iOS 6中提到的解决方法崩溃发行说明

At last i avoided crash by following the workaround mentioned in Apple's iOS 6 release notes.

解决方法:

1。应用应提供委托方法 应用程序:supportedIntefaceOrientationsForWindow并确保该肖像是返回的掩码值之一。

1.Apps should provide the delegate method application:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{

    return UIInterfaceOrientationMaskAllButUpsideDown;
}

2。当涉及UIBNavigationController(或UIViewController)时,继承UINavigationController / UIViewController并覆盖supportedInterfaceOrientations。

 - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }

在buid摘要支持的方向中选择了横向右侧和横向左侧。

In buid summary supported orientations selected landscape right and landscape left.

现在游戏中心工作正常而不会崩溃。

Now game center is working properly without crash.

这篇关于游戏中心仅在i OS 6中登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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