Xcode(最新ver.)でGAMECENTERの機能を搭載したアプリを実装しているのですが、ログインしていない場合、ログイン画面を出すという処理を書いていても「Player is not signed in」と出てしまい、ログインできません。
端末でサンドボックスをONにすると自動的にログインできるのですが、これはユーザーが自身でサンドボックスをONにしていなければログインできない仕組みなのでしょうか?
それともユーザーが特に設定することもなくコードでログイン画面を表示できるようにできるのでしょうか?
(以前(Xcodeをアップデート・ios7の時)はこちらのコードと同じコードで実装しても自動的にログイン画面が出るようになり「Player is not signed in」のエラーが出ませんでした。)
コードはこちらです。
-
(void)worldlank:(UIButton*)button{
GKGameCenterViewController *gcView = [GKGameCenterViewController new];
if (gcView != nil)
{
gcView.gameCenterDelegate = self;
gcView.viewState = GKGameCenterViewControllerStateLeaderboards;
[self presentViewController:gcView animated:YES completion:nil];
}if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKScore* score = [[GKScore alloc] initWithLeaderboardIdentifier:@"2048"];
score.value = bestScore;
[GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
if (error) {
// エラーの場合
}
}];
}
}
//ゲームセンター認証
- (void)authenticateLocalPlayer
{
GKLocalPlayer* player = [GKLocalPlayer localPlayer]; player.authenticateHandler = ^(UIViewController* ui, NSError* error ) { if( nil != ui ) { [self presentViewController:ui animated:YES completion:nil]; } };
}
/**
- リーダーボードで完了タップ時の処理
- 前の画面に戻る
*/
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
あなたの回答
tips
プレビュー