Reputation: 1198
I'm trying to make a leaderboard for a game I created using SpriteBuilder. I have the following code.
if (gameCenterController != nil)
{
gameCenterController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: gameCenterController animated: YES completion:nil];
}
However, on the UIViewController *vc line, I keep getting the following error, "Property 'view' not found on object of type 'MainScene *'.
I have been searching for hours, does anyone know of a solution for this?
Upvotes: 2
Views: 733
Reputation: 1198
I actually answered my own question! :D
UIViewController *vc = [[[[CCDirector sharedDirector] view] window] rootViewController];
Upvotes: 0
Reputation: 5026
MainScene does not have a view
property because it isn't a UIViewController
.
There is only one UIViewController
in a Cocos2d application and that is the CCDirector
.
If you want to present a view controller you need to present it from the CCDirector
:
[[CCDirector sharedDirector] presentViewController:vc animated:YES completion:nil];
Upvotes: 3