游戏中心iOS 7不工作

游戏中心iOS 7不工作,ios,ios7,game-center,leaderboard,Ios,Ios7,Game Center,Leaderboard,遵循Ray Wenderlich关于使用iOS 7实现游戏中心的教程 然而,我没有收到登录提示,欢迎回来的横幅也没有出现,我尝试了许多教程,似乎无法让它与iOS 7一起工作 这是我的密码 GCHelper.h #import <Foundation/Foundation.h> #import <GameKit/GameKit.h> @interface GCHelper : NSObject { BOOL gameCenterAvailable; BO

遵循Ray Wenderlich关于使用iOS 7实现游戏中心的教程

然而,我没有收到登录提示,欢迎回来的横幅也没有出现,我尝试了许多教程,似乎无法让它与iOS 7一起工作

这是我的密码

GCHelper.h

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface GCHelper : NSObject {
    BOOL gameCenterAvailable;
    BOOL userAuthenticated;
}

@property (assign, readonly) BOOL gameCenterAvailable;

+ (GCHelper *)sharedInstance;
- (void)authenticateLocalUser;

@end
#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface gamecentercontrol : NSObject {

    BOOL gameCentreAvailable;
    BOOL userAuthenticated;

}

@property (assign, readonly) BOOL gameCentreAvailable;

+ (gamecentercontrol *)sharedInstance;

-(void)authenticateLocalUser;


@end
在我的应用程序中完成了我的启动方法

[[GCHelper sharedInstance] authenticateLocalUser];
是因为我不推荐使用authenticateWithCompletionHandler吗?

#从apple示例代码导入“GameCenterManager.h”。将您的项目目标设置为iOS 6.0将代码放入viewdidload它将正常工作

   @property (nonatomic, retain) GameCenterManager *gameCenterManager;

    if([GameCenterManager isGameCenterAvailable])
      {
        self.gameCenterManager= [[GameCenterManager alloc] init];
            [self.gameCenterManager setDelegate: self];
        [self.gameCenterManager authenticateLocalUser];
        }

下面是我使用iOS7显示游戏中心登录的代码

gamecentercontrol.h

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface GCHelper : NSObject {
    BOOL gameCenterAvailable;
    BOOL userAuthenticated;
}

@property (assign, readonly) BOOL gameCenterAvailable;

+ (GCHelper *)sharedInstance;
- (void)authenticateLocalUser;

@end
#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface gamecentercontrol : NSObject {

    BOOL gameCentreAvailable;
    BOOL userAuthenticated;

}

@property (assign, readonly) BOOL gameCentreAvailable;

+ (gamecentercontrol *)sharedInstance;

-(void)authenticateLocalUser;


@end

在视图控制器文件中,您希望它完成身份验证的任何位置。

@sami-输入您的代码authentication@VivekSehrawat我已经添加了我的code@Sami-你看过Gktaper的苹果示例代码吗?是的,我看过并试着实现它,但是运气不好。@sami-你试过我的答案了吗?请使用下面的链接设置游戏中心和领队板。“”欢迎来到Stack Overflow!虽然这个代码片段可以解决这个问题,但它确实有助于提高文章的质量。请记住,您将在将来回答读者的问题,这些人可能不知道您的代码建议的原因。
///////just Update the method 

- (void) authenticateLocalPlayer

{

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{


viewController=[[UIViewController alloc] init];

         if (viewController != nil)

         {

             //showAuthenticationDialogWhenReasonable: is an example method name. Create your own method that displays an authentication view when appropriate for your app.

             [self showAuthenticationDialogWhenReasonable: viewController];

         }

         else if (localPlayer.isAuthenticated)

         {

             //authenticatedPlayer: is an example method name. Create your own method that is called after the local player is authenticated.

             [self authenticatedPlayer: localPlayer];

         }

         else

         {

             [self disableGameCenter];

         }

     };

}
///////just Update the method 

- (void) authenticateLocalPlayer

{

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{


viewController=[[UIViewController alloc] init];

         if (viewController != nil)

         {

             //showAuthenticationDialogWhenReasonable: is an example method name. Create your own method that displays an authentication view when appropriate for your app.

             [self showAuthenticationDialogWhenReasonable: viewController];

         }

         else if (localPlayer.isAuthenticated)

         {

             //authenticatedPlayer: is an example method name. Create your own method that is called after the local player is authenticated.

             [self authenticatedPlayer: localPlayer];

         }

         else

         {

             [self disableGameCenter];

         }

     };

}