Class

GKGameCenterViewController

A single user interface used to display achievements and leaderboards supported by Game Center.

Declaration

iOS, Mac Catalyst, tvOS
@interface GKGameCenterViewController : UINavigationController
macOS
@interface GKGameCenterViewController : NSViewController

Overview

To display the Game Center screen, initialize a new GKGameCenterViewController object and set its delegate. Optionally, you can choose to configure the view controller further to specify which content is initially displayed. Then present the view controller. Your delegate is called when the user dismisses the screen. Listing 1 shows how to present a new GKGameCenterViewController and display the scores for a specific leaderboard.

Listing 1

Displaying the leaderboard page of the Game Center user interface

- (void) showLeaderboard: (NSString*) leaderboardID
{
    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil)
    {
       gameCenterController.gameCenterDelegate = self;
       gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
       gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeToday;
       gameCenterController.leaderboardCategory = leaderboardID;
       [self presentViewController: gameCenterController animated: YES completion:nil];
    }
}

Your game should pause other activities before presenting the Game Center user interface.

Topics

Configuring the Game Center View Controller’s Delegate

gameCenterDelegate

The view controller’s delegate.

GKGameCenterControllerDelegate

The delegate is called when the player dismisses the Game Center user interface.

Configuring the Game Center Controller’s Content

viewState

The content displayed by the Game Center controller.

GKGameCenterViewControllerState

Possible values for the viewState property.

leaderboardIdentifier

The named leaderboard that is displayed by the view controller.

leaderboardCategory

The named leaderboard that is displayed by the view controller.

Deprecated
leaderboardTimeScope

A time filter used to restrict which scores are displayed to the player.

Relationships

Conforms To

See Also

View Controllers

GKDialogController

An object that provides the ability to present Game Center view controller classes in macOS.

GKViewController

The abstract base protocol adopted by Game Center view controller classes.