解雇GKGameCenterViewController

时间:2013-12-11 22:51:36

标签: ios objective-c

我一直在尝试没有成功解雇GKGameCenterViewController视图对象,但它似乎不起作用;点击游戏中心视图控制器中的完成按钮似乎没有注意。以下是代码:

//Header File:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "Constants.h"
#import "GameManager.h"
#import "SimpleAudioEngine.h"
#import "MenuManager.h"
#import "GamePlayScene.h"

@interface MainMenuLayer : CCLayer {
CCMenu *mainMenu;
CCMenu *sceneSelectMenu;
CCMenu *socialMediaMenu;
}
@end

//View Controller stuff:
@interface myViewController : UIViewController<GKGameCenterControllerDelegate>

-(void)displayGameCenter; //called inside the menu layer
-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController    *)gameCenterViewController;
@end


//Implementation file:
#import "MainMenuLayer.h"
#import "GamePlayScene.h"

@implementation myViewController

-(void)displayGameCenter{
UIViewController *rootVC = [UIApplicationsharedApplication].keyWindow.rootViewController;

GKGameCenterViewController *gameCenterController;
gameCenterController= [[GKGameCenterViewController alloc] init];

if (gameCenterController != nil)
{
    gameCenterController.gameCenterDelegate = self;
    gameCenterController.viewState = GKGameCenterViewControllerStateDefault;
    [rootVC presentViewController: gameCenterController animated: YES completion:nil];

    //[self gameCenterViewControllerDidFinish:gameCenterController]; }
}        
-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController    *)gameCenterViewController{

[self dismissViewControllerAnimated:YES completion:nil];

}

@end

0 个答案:

没有答案