2012-09-19 21 views
20

Cuando se carga Game Center, su orientación predeterminada es vertical. Para bloquearlo en modo horizontal, se agregó una categoría.Bloqueo de inicio de sesión en el centro del juego solo en i OS 6

@implementation GKMatchmakerViewController (LandscapeOnly) 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (BOOL)shouldAutorotate { 
    return NO; 
} 
@end 

Funciona bien en iOS 6 debajo. Pero en iOS6 muestra un error.

Terminación de aplicación debido a excepción no detectada 'UIApplicationInvalidInterfaceOrientation', razón: 'orientaciones compatibles no tiene ninguna orientación común con la solicitud, y shouldAutorotate está volviendo SÍ'

favor explicar una solución.

Respuesta

39

Por fin evité colapsar siguiendo la solución mencionada en iOS 6 release notes de Apple.

Solución:

1.Apps should provide the delegate methodapplication:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window 
{ 

    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

2. Cuando se trata de un UIBNavigationController (o un UIViewController), subclase la UINavigationController/UIViewController y supportedInterfaceOrientations primordiales.

- (NSUInteger)supportedInterfaceOrientations 
    { 
     return UIInterfaceOrientationMaskLandscape; 
    } 

Y

In buid summary supported orientations selected landscape right and landscape left.

Ahora centro de juego funciona correctamente y sin accidente.

+0

impresionante! Me salvaste el culo :) – yonix

+0

¡Gracias! También se guardó mi culo :) –

+1

Funcionó también para mí, pero en mi caso no estaba usando un UIBNavigationController sino un UIViewController (su subclase), pero aún así tuve que agregar el método número 2 en él. Es posible que desee reemplazar UIBNavigationController con UIViewController en esta respuesta. –

0

Tengo que añadir 1 pequeña cosa. Luchando con ese estúpido problema de 2 días. Si anteriormente no ayuda y tiene UINavigationController invovled (y que ya tenía una subclase) se necesita lo siguiente (en AppDelegate):

[window setRootViewController:navigationController]; // use this 
// instead of [self.window addSubview:navigationController.view]; 

Gracias 2 http://grembe.wordpress.com/2012/09/19/here-is-what-i/

Cuestiones relacionadas