Note that there are some explanatory texts on larger screens.

plurals
  1. POBizarre GameKit behavior. Anyone else seeing this?
    primarykey
    data
    text
    <p>I am running Xcode 4.3.3 and am targeting iOS 5.1. I am attempting to include Game Center functionality in a game.</p> <p>When authenticating the GKLocalPlayer the user is presented with the <em>Sign in to Game Center</em> alert view or shown to be logged in. So far this is all fine, but if the user presses the <em>Create New Account</em> button then any open modal views are moved behind the root view controller and the following error is spit from the console:</p> <blockquote> <p>Unbalanced calls to begin/end appearance transitions for &lt;GKModalRootViewController: <em>memory address</em>&gt;.</p> </blockquote> <p>I have tried moving the GKLocalPlayer authentication code between the app delegate and the root view controller. I have also tried implementing the authentication in a new, blank project. I have tried it with and without Storyboards and ARC. In all of these cases the results were the same: modals hidden behind the root view controller and error given.</p> <p>Here is the GKLocalPlayer authentication method I am calling from my app delegate’s <em>application:didFinishLaunchingWithOptions:</em> method:</p> <pre><code>- (void)authenticateLocalPlayer { GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; [localPlayer authenticateWithCompletionHandler:^(NSError *error) { if (localPlayer.isAuthenticated) { // Perform additional tasks for the authenticated player. } else { // Disable Game Center features. } if (error) { // Handle error. } }]; } </code></pre> <p><a href="http://lanausee.com/files/wonkygamekit.png" rel="nofollow noreferrer">Here</a> is a screenshot of it. In this picture the root view controller has a background with a 50% alpha value. The modal has been pushed behind the root view controller by this bug.</p> <p><a href="https://stackoverflow.com/questions/8049118/unbalanced-calls-to-begin-end-appearance-transitions-for-gkmodalrootviewcontrol">This stackoverflow question</a> contains the only reference to this error (regarding GKModalRootViewController) I can find, and it doesn't fit since (a.) I’m not using cocos2d. (b.) It happens whether or not I perform a segue, and I am not touching viewWillAppear: or viewDidAppear:. (c.) No acceptable answer was given.</p> <p><a href="https://stackoverflow.com/questions/11008613/game-center-white-screen-after-create-account">This question</a> and <a href="https://stackoverflow.com/questions/10561309/underlying-view-disappears-during-game-center-authentication">this one</a> seem to involve the same issue (with the view hierarchy being destroyed) but are unanswered and don’t mention the console error message.</p> <p>Does this happen for anyone else? Any ideas on what could be causing this?</p> <p><strong>UPDATE 1:</strong> I went so far as to put the authentication code into an IBAction connected to a button in the modal view so as to avoid any initialization conflicts. It didn't help.</p> <p><strong>UPDATE 2:</strong> I tried moving the authentication code into a GCD background queue. he results were the same.</p> <p><a href="http://lanausee.com/files/gamecenter-test.zip" rel="nofollow noreferrer">Here</a> is the test project (which is GameCenter ready with my app's Bundle ID already entered).</p> <p>To test:</p> <ol> <li>Log out of Game Center on the test device/simulator (if you are logged in).</li> <li>Build and run the app.</li> <li>Press the info button.</li> <li>Press <em>Authenticate</em>.</li> <li>When the Sign in to Game Center alert appears press <em>Create New Account</em>.</li> <li>Press <em>Cancel</em>.</li> <li>Did the “Unbalanced calls...” message appear in the console? Did the modal view (with the Authenticate button) disappear?</li> <li>Press the info button.</li> <li>Did the modal display again?</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload