Game Center ViewController not appearing when testing on phone

600 Views Asked by At

I'm using iOS6 and my phone is a 4S.

I'm using code from the GKLeaderboards example to get Game Center working and the local player authenticated. This code I've imported into my own Sparrow framework scaffold project.

This seems to work totally fine on the simulator, I get the "welcome back xxxx, ** sandbox mode *" msg.

But when I test it on the actual iPhone, my game (which right now just consists of lots of tiles on the screen) slows down to a crawl, and no Game Center msg appears.

Looking at code, because I'm logged in with a different Game Center account on the phone (i'e not the sandbox one) then I think it's trying to present the log in with new account view, but it's not appearing.

The code I'm using is...

localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
            // If there is an error, do not assume local player is not authenticated.
            if (viewController != nil)
            {
                [mainViewController presentViewController:viewController animated:NO completion:nil];
                //store this view controller pointer
                NSLog(@"viewController != nil");

            }
            else if (localPlayer.isAuthenticated)
            {
                NSLog(@"Authentication changed: player authenticated.");
            }
            else
            {
              NSLog(@"can't log in");
            }
           }

I think the problem is being caused by this line...

[mainViewController presentViewController:viewController animated:NO completion:nil];

The game doesn't seem to crash but there seems to be something going wrong causing it all to slow right now, any ideas as to what could cause this?

1

There are 1 best solutions below

0
Phil On

Ok I seem to have gotten this working. Basically I didn't have mainViewController set properly.