Game Center don't show login window in device

Game Center integration works fine in all simulators, but when runs in a device the login window is not showed. The device is reseted.The following code (summarize):

-(UIViewController*) topViewController
{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController)
{
topController = topController.presentedViewController;
}
return topController;
}

-(void) login
{
GKLocalPlayer *player = [GKLocalPlayer localPlayer];
void (^authBlock)(UIViewController *, NSError *) = ^(UIViewController *viewController, NSError *error) {

    if (viewController)
    {
        [[self topViewController] presentViewController:viewController animated:YES completion:nil];
    }
};
[player setAuthenticateHandler:authBlock];

}

the line “if(viewController)” return true in simulator and false in device.Why?