2012-09-19 8 views
20

Po załadowaniu centrum gier jego domyślną orientacją jest portret. Aby zablokować go w trybie poziomym, dodano kategorię.Blokada logowania do centrum gier w krajobrazie tylko w systemie iOS 6

@implementation GKMatchmakerViewController (LandscapeOnly) 

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

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

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

Działa poprawnie w wersjach poniżej iOS 6. W systemie iOS6 pokazuje jednak błąd.

Zakończenie aplikację spowodowane nieprzechwyconego wyjątku „UIApplicationInvalidInterfaceOrientation”, powód: „Obsługiwane orientacje ma wspólną orientację z aplikacją i shouldAutorotate wraca TAK”

Proszę wyjaśnić rozwiązanie.

Odpowiedz

39

W końcu uniknąłem awarii, wykonując obejście wspomniane w systemie iOS 6 release notes firmy Apple.

Rozwiązanie:

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. Gdy UIBNavigationController (lub UIViewController) bierze udział, podklasy UINavigationController/UIViewController i nadrzędne supportedInterfaceOrientations.

- (NSUInteger)supportedInterfaceOrientations 
    { 
     return UIInterfaceOrientationMaskLandscape; 
    } 

I

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

teraz Center gra działa poprawnie bez awarii.

+0

Awesome! Uratowałeś mi tyłek :) – yonix

+0

Dzięki! Mój tyłek też był zapisany :) –

+1

Pracował również dla mnie, ale w moim przypadku nie korzystałem z UIBNavigationController, ale z UIViewController (jego podklasy), jednak wciąż musiałem dodać do niego numer metody 2. W tej odpowiedzi można zamienić UIBNavigationController na UIViewController. –

0

Dodać jedną małą rzecz. Walcząc z tym głupim problemem około 2 dni. Jeśli powyżej nie pomaga i trzeba UINavigationController invovled (i już nie podklasy go) potrzebne są następujące (w appDelegate):

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

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

Powiązane problemy