0

When showing the achievements dialog using GKAchievementViewController, this works as expected.

However, when showing the leaderboard dialog using GKLeaderboardViewController, I simply a grey screen and no Done button. Furthermore, it appears to be in the wrong orientation on an iPhone.

Here is the code:

this.leaderboardController.TimeScope = GKLeaderboardTimeScope.AllTime; this.leaderboardController.Category = "myLeaderboardId"; this.leaderboardController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; this.leaderboardController.DidFinish += (senderLeaderboard, eLeaderboard) => { this.leaderboardController.DismissViewController(true, null); }; viewController.PresentViewController(this.leaderboardController, false, null);

I am using the same view controller that I use for showing the achievements dialog from Game Center.

I cannot dismiss the leaderboard dialog because it does not even have a 'Done' button.

L. Desjardins
  • 1,465
  • 1
  • 12
  • 22
  • Have you tried removing `UIModalPresentationStyle.FormSheet`? These GameKit controllers should handle the presentation style they want. – jonathanpeppers Mar 06 '14 at 15:48
  • Yes this is what I had initially tried (ie not setting the ModalPresentationStyle). – L. Desjardins Mar 06 '14 at 19:27
  • Okay! My previous comment is inaccurate, I must have not tried this actually - I just removed setting UIModalPresentationStyle.FormSheet altogether and it is now oriented correctly! However - there is still no 'Done' button :s so I cannot dismiss this view. – L. Desjardins Mar 06 '14 at 19:55
  • Another observation I had is that if I set the animate property to 'true', then I do not see any data at all. I need to have the animate property (in PresentViewController) to be false in order to see my leaderboard data. However there is still something wrong with the title bar, since there is no Done button and no title like there is when presenting GKAchievementViewController (which works just fine). – L. Desjardins Mar 06 '14 at 20:11

1 Answers1

0

Okay, the problem was that I was initializing the view controller in the constructor of my class. This was too early, instead I lazy-initialize (initialize only if\when needed). This fixed all the above mentioned problems.

L. Desjardins
  • 1,465
  • 1
  • 12
  • 22