0

我开发的游戏只支持 ios 4.3 以上设备的横向模式。该应用程序在 ios 6 设备上实现了 gamecenter 并在测试期间崩溃,因为 gamecenter 登录屏幕不支持 ios 6 中的横向模式。所以我修复了将以下代码添加到 appdelegate.m 并开始工作但现在应用程序显示完全有线的问题(在 ios6(ios5 等)以下的设备上显示纵向倒置)

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else // iphone
        return UIInterfaceOrientationMaskAllButUpsideDown;
}

使用 xcode:4.5 cocos2d v1.0.1

请帮我解决这个问题

4

2 回答 2

1

在您的项目中添加给定的类

GKMatchmakerViewController-LandscapeOnly.h

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface GKMatchmakerViewController(LandscapeOnly)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

GKMatchmakerViewController-LandscapeOnly.m


#import "GKMatchmakerViewController-LandscapeOnly.h"

@implementation GKMatchmakerViewController (LandscapeOnly)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
}

@end
于 2013-01-15T08:44:24.463 回答
0

替换这行代码 [window addSubview: viewController.view]; 在 AppDelegate.m 中低于一个

//************************************************************************
    NSString *reqSysVer = @"6.0";
    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
    {
        [window setRootViewController:viewController];
    } else
    {
        [window addSubview: viewController.view];
    }
    //************************************************************************

并在 RootViewController.m 添加以下代码

///////********************************/////////

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead of shouldAutorotateToInterfaceOrientation

- (NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutorotate {
    return YES;
}

///////********************************/////////
于 2013-08-25T22:05:13.440 回答