[英]game center not working on ipod/iphone
Hi all Working on a universal build for an iphone/ipod/ipad app. 大家好正在为iPhone / iPod / iPad应用程序构建通用版本。 I was trying to get game center working within this app.
我试图让游戏中心在此应用中正常工作。 I now have the game center working on the ipad but for some reason it still wont work on the ipod/iphone and i have no idea why.
我现在在ipad上有游戏中心,但是由于某种原因它仍然不能在ipod / iphone上工作,我也不知道为什么。
highScoreVC=[[UIViewController alloc] init];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:highScoreVC.view];
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
this is my code for displaying the leaderboard and it does work everytime for ipad but as i said not for other devices. 这是我用于显示排行榜的代码,它每次都适用于ipad,但正如我所说,不适用于其他设备。 the code is still being called the same as for ipad so i have no clue why it is not displaying.
该代码仍被称为与ipad相同,因此我不知道为什么它不显示。 any ideas why this would be?
任何想法为什么会这样? cheers
干杯
As far as I'm concerned, [GKLeaderboardViewController init]
will return nil
if the device is not authenticated with Game Center by that point. 就我而言,如果该设备尚未通过Game Center进行身份验证,则
[GKLeaderboardViewController init]
将返回nil
。 Are you sure you are correctly authenticated on the devices causing problems? 您确定在引起问题的设备上正确进行了身份验证吗?
I suspect there may be some issues with how your UIKit items for Game Center are being displayed if they are working fine on the iPad but not iPhone/iPod. 我怀疑如果在iPad上无法正常使用GameKit的UIKit项,但在iPhone / iPod上不能正常运行,可能会出现一些问题。 I experienced similar sounding issues when converting an app to universal.
将应用程序转换为通用程序时,我遇到了类似的听起来问题。
If you create a new standalone iPhone/iPod project just for testing does game center display fine? 如果您创建一个新的独立iPhone / iPod项目只是为了进行测试,那么游戏中心是否可以正常显示?
ok i got it working in the end. 好吧,我最终得到了它。 cocos2d 0.99.5 has indeed made some changes that to how this works.
cocos2d 0.99.5确实对其工作方式进行了一些更改。 the following code displays the leaderboard correctly
以下代码正确显示排行榜
-(UIViewController*) getRootViewController{
return (UIViewController*)([(BubbleDreamsAppDelegate*) [[UIApplication sharedApplication] delegate] viewController]);
} }
and then 接着
highScoreVC = [self getRootViewController];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
hope this helps anyone that gets stuck with same problem 希望这对遇到同样问题的人有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.