gpt4 book ai didi

iphone - 显示游戏中心 GKMatchmakerViewController 关闭其他 View

转载 作者:行者123 更新时间:2023-11-29 04:11:30 24 4
gpt4 key购买 nike

我在尝试在游戏 View 上显示 GKMatchmakerViewController 时遇到问题。

通常情况下,我会通过自动匹配 2 个对手来以编程方式创建多人比赛,效果很好。

但是当我尝试显示标准的 Game Center Matchmaking View 时,它会关闭我的游戏 View 并将我推回到菜单。

菜单 View -> 游戏 View 。

我认为问题可能是我的菜单 View 充当了我的主视图,并且当显示 Game Center View 时所有其他 View 都被删除(因为当时只能显示一个 View Controller )。

我的 View 层次结构设置错误吗?应该如何做才能使我的游戏 View 在显示游戏中心 View 时不会被关闭?

编辑 - 使用调用 GKMatchMakerViewController 的代码进行更新

GameviewController 以及当我想要显示 Game Center 匹配 Controller 时调用的方法

  - (void)presentCustomVSBattle {

ourRandom = arc4random();
[self setGameState:kGameStateWaitingForMatch];

AppDelegate * delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;


[[GCHelper sharedInstance] findCustomMatchWithMinPlayers:2 maxPlayers:2 viewController:delegate.viewController delegate:self];
}

//GCHelper.m中调用该方法

 - (void)findCustomMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController delegate:(id<GCHelperDelegate>)theDelegate {

if (!gameCenterAvailable) return;

matchStarted = NO;
self.match = nil;
self.presentingViewController = viewController;
delegate = theDelegate;

if (pendingInvite != nil) {

[presentingViewController dismissModalViewControllerAnimated:NO];
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:pendingInvite] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentViewController:mmvc animated:YES completion:nil];

self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
}
else {

[presentingViewController dismissModalViewControllerAnimated:NO];
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.playersToInvite = pendingPlayersToInvite;

GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;

[presentingViewController presentViewController:mmvc animated:YES completion:nil];

self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;

}

}

最佳答案

在您的情况下,dismissView Controller 调用看起来没有必要,请尝试摆脱它们:)

关于iphone - 显示游戏中心 GKMatchmakerViewController 关闭其他 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14334496/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com