我在我的遊戲中實現了實時遊戲中心,並且我在介紹GKMatchmakerViewController
時遇到了問題。這裏是我的情況:如何將GKMatchmakerViewController呈現給視圖控制器?
有HomeViewController在我提出
GameViewController
與下面的代碼:GameViewController *gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil]; gameViewController.delegate = self; [self presentViewController:gameViewController animated:NO completion:nil];
然後在
GameViewController
我包括GCHelper
,並呼籲遊戲中心開始比賽:-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[GCHelper sharedInstance] authenticateLocalUser]; [[GCHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:2 viewController:self delegate:(id)self]; }
問題是那我從遊戲中心那個小小的提醒又回來了:
但是遊戲中心的大窗口沒有顯示。我相信這個問題是因爲我在展示GameViewController
。
我該如何解決這個問題?
UPDATE:
當我嘗試調用遊戲中心HomeViewConroller,一切都運行完美。
更新2(嘗試): 我GCHelper嘗試,而不是:
[presentingViewController presentViewController:mmvc animated:YES completion:nil];
使用:
AppDelegate * appdelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[appdelegate.homeViewController presentViewController:mmvc animated:YES completion:nil];
但後來我得到錯誤: 誰的觀點是不是在窗口層次!
實際登錄名是顯示您還沒有登錄遊戲,根據您已經登錄 –
正確的圖形,但與此代碼必須顯示在遊戲中心:[GCHelper sharedInstance] findMatchWithMinPlayers:2個MAXPLAYERS:2 viewController:self delegate:(id)self]; – CroiOS
我正在發送整個密碼給你 –