ios - 无法关闭 Game Center 排行榜页面
<p><p>我可以毫无问题地加载排行榜。但是当点击“完成”按钮时,我无法关闭它。</p>
<p>我如何打开它:</p>
<pre><code>- (IBAction)leaderboardsClicked:(id)sender{
if (.isAuthenticated) {
GKGameCenterViewController *leaderboardController = [ init];
;
}else{
UIAlertView *alert = [initWithTitle: @"Error"
message: @"You must be logged into Game Center to view the leaderboards. Open Game Center?"
delegate: self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
;
}
}
</code></pre>
<p>我是如何关闭它的:</p>
<pre><code>- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController{
NSLog(@"test");
;
}
</code></pre>
<p><strong>编辑:</strong></p>
<p>该方法根本没有运行;所以“测试”甚至不会被打印出来。</p>
<p>我将 <code><GKGameCenterControllerDelegate></code> 添加到我的 ViewController 的协议(protocol)中。 </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个:</p>
<pre><code>- (IBAction)leaderboardsClicked:(id)sender{
if (.isAuthenticated) {
GKGameCenterViewController *leaderboardController = [ init];
leaderboardController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
;
}else{
UIAlertView *alert = [initWithTitle: @"Error"
message: @"You must be logged into Game Center to view the leaderboards. Open Game Center?"
delegate: self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
;
}
}
</code></pre>
<p>还有:</p>
<pre><code>- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController*) gameCenterViewController {
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 无法关闭 Game Center 排行榜页面,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/25577584/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/25577584/
</a>
</p>
页:
[1]