我正在开发一个游戏中心多人游戏应用程序,我发现了一些让我挠头的东西。只要两个设备都没有启动并运行 GKMatchmakerViewController,我就可以很好地接收游戏邀请。但是,当两个设备都打开它并发出邀请时,用户在警报横幅上选择“接受”后什么也没有发生。有没有很好的工作示例可以展示如何做到这一点?我正在与 Ray Wenderlich 的 GCHelper 合作,几周来在这个问题上没有取得任何进展。
[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;
}
};
我认为这个问题与“
警告:在演示过程中尝试演示!
我需要做什么来解决这个问题?