Forum Xamarin Xamarin.iOS

GKGameCenterViewControllerState in iOS 7

HavenFalkHavenFalk USMember
edited April 2014 in Xamarin.iOS

Do the GKGameCenterViewControllerState values for GKGameCenterViewController.ViewState work correctly with Xamarin.iOS for iOS 7? For example:

var gameCenterController = new GKGameCenterViewController();
gameCenterController.ViewState = GKGameCenterViewControllerState.Achievements;

That code correctly shows the achievements tab in Game Center for me in iOS 6, but in iOS 7, the most recently viewed Game Center tab (e.g., Leaderboards) is shown regardless of what gameCenterController.ViewState is set to.

I'm not sure if this is an iOS 7 bug, or a Xamarin bug related to iOS 7. Any ideas?


  • HavenFalkHavenFalk USMember

    I figured this out. In case it's helpful for anyone else, here's the code that's working for me:

    var gameCenterController = new GKGameCenterViewController();
    gameCenterController.Finished += delegate(object sender, EventArgs e) {
        gameCenterController.DismissViewController(true, delegate {});
    gameCenterController.ViewState = GKGameCenterViewControllerState.Leaderboards;
    window.RootViewController.PresentViewController (gameCenterController, true, delegate {});

    I believe the problem was that I had been using a persistent member variable for gameCenterController instead of a local variable (i.e., var gameCenterController), and I don't think GKGameCenterViewController instances are designed to stick around and be opened, closed, and reopened. It seems best just to declare the variable locally and let it go out of scope when it's done.

Sign In or Register to comment.