GKGameCenterViewController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in iOS 6.0 and later.
Companion guide
Declared in
GKGameCenterViewController.h

Overview

The GKGameCenterViewController class aggregates many common Game Center features into a single user interface. It replaces GKAchievementViewController and GKLeaderboardViewController as the preferred way to show Game Center content in your game.

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.

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

Tasks

Configuring the Game Center View Controller’s Delegate

Configuring the Game Center Controller’s Content

Properties

gameCenterDelegate

The view controller’s delegate.

@property(nonatomic, assign) id<GKGameCenterControllerDelegate> gameCenterDelegate
Discussion

Before displaying the view controller, your game must set a delegate.

Availability
  • Available in iOS 6.0 and later.
Declared In
GKGameCenterViewController.h

viewState

The content displayed by the Game Center controller.

@property(nonatomic, assign) GKGameCenterControllerViewState viewState
Discussion

See “Game Center Controller View State” for possible values. When you first present the Game Center view controller, the content displayed by the view controller is determined by this property. If the player navigates to different content, the view state is automatically updated. For example, to preserve the player’s selections, you can read the viewState property after the screen is dismissed, and set that value the next time you initialize the view controller.

Availability
  • Available in iOS 6.0 and later.
Declared In
GKGameCenterViewController.h

Constants

Game Center Controller View State

Possible values for the viewState property.

typedef enum /*: NSInteger */ {
   GKGameCenterViewControllerStateDefault = -1,
   GKGameCenterViewControllerStateLeaderboards ,
   GKGameCenterViewControllerStateAchievements,
   GKGameCenterViewControllerStateChallenges,
} GKGameCenterViewControllerState;
Constants
GKGameCenterViewControllerStateDefault

Indicates that the view controller should present the default screen.

Available in iOS 6.0 and later.

Declared in GKGameCenterViewController.h.

GKGameCenterViewControllerStateLeaderboards

Indicates that the view controller presents leaderboard content. The leaderboardCategory and leaderboardTimeScope properties affect the appearance of this view state.

Available in iOS 6.0 and later.

Declared in GKGameCenterViewController.h.

GKGameCenterViewControllerStateAchievements

Indicates that the view controller presents achievements content.

Available in iOS 6.0 and later.

Declared in GKGameCenterViewController.h.

GKGameCenterViewControllerStateChallenges

Indicates that the view controller presents challenges content.

Available in iOS 6.0 and later.

Declared in GKGameCenterViewController.h.