Iphone 当GKMatchmakerViewController打开时,您如何接收游戏中心邀请?
我正在开发一个游戏中心多人应用程序,我发现了一些让我抓狂的东西。只要两台设备都没有GKMatchmakerViewController启动并运行,我就可以收到游戏邀请。但是,当两台设备都打开并发出邀请时,用户在警报横幅上选择“接受”后不会发生任何事情。有没有什么好的例子可以说明如何做到这一点?我正在与Ray Wenderlich的GCHelper合作,已经有好几个星期没有在这个问题上取得任何进展Iphone 当GKMatchmakerViewController打开时,您如何接收游戏中心邀请?,iphone,objective-c,cocos2d-iphone,game-center,multiplayer,Iphone,Objective C,Cocos2d Iphone,Game Center,Multiplayer,我正在开发一个游戏中心多人应用程序,我发现了一些让我抓狂的东西。只要两台设备都没有GKMatchmakerViewController启动并运行,我就可以收到游戏邀请。但是,当两台设备都打开并发出邀请时,用户在警报横幅上选择“接受”后不会发生任何事情。有没有什么好的例子可以说明如何做到这一点?我正在与Ray Wenderlich的GCHelper合作,已经有好几个星期没有在这个问题上取得任何进展 [GKMatchmaker sharedMatchmaker].inviteHandler
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
NSLog(@"Received invite!!!");
self.pendingInvite = acceptedInvite;
self.pendingPlayersToInvite = playersToInvite;
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));
NSString *reqSysVer = @"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer
options:NSNumericSearch] != NSOrderedAscending);
gameCenterAvailable=gcClass && osVersionSupported;
if (!gameCenterAvailable) return;
matchStarted = NO;
self.match = nil;
if (acceptedInvite) {
NSLog(@"pendingInvite != nil");
AppDelegate *gcdelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[gcdelegate.viewController dismissModalViewControllerAnimated:YES];
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:pendingInvite];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
boo_invite=true;
}
else {
NSLog(@"pendingInvite == nil");
AppDelegate *gcdelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[gcdelegate.viewController dismissModalViewControllerAnimated:NO];
request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.playersToInvite = pendingPlayersToInvite;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController dismissModalViewControllerAnimated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
}
};
我认为这个问题与""
警告:试图显示
在演示文稿进行时打开
进步
我需要做些什么来修复此问题?看起来问题在于没有等待足够长的时间来解除控制器
[gcdelegate.viewController dismissViewControllerAnimated:YES
completion:^{
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:pendingInvite];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
boo_invite=true;
}];
处理好了