Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Game center login lock in landscape only in i OS 6

Tags:

When Game center is loaded its default orientation is portrait. In order to lock it in landscape mode, added a category.

@implementation GKMatchmakerViewController (LandscapeOnly)

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

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

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

It is working fine in below iOS 6 .But in iOS6 it shows an error.

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

Please explain a solution.

like image 779
Minna Avatar asked Sep 19 '12 04:09

Minna


People also ask

Why is my keyboard sideways on Facebook?

Go to General > Accessibility > AssistiveTouch. Make sure the toggle at the top of the screen is in the On position. Tap one of the four options (Single Tap, Double Tap, Long Press, or 3D Touch) and set it to Open Menu.


1 Answers

At last i avoided crash by following the workaround mentioned in Apple's iOS 6 release notes.

Workaround:

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

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

    return UIInterfaceOrientationMaskAllButUpsideDown;
}

2. When a UIBNavigationController (or a UIViewController) is involved, subclass the UINavigationController/UIViewController and overriding supportedInterfaceOrientations.

 - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }

And

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

Now game center is working properly without crash.

like image 87
Minna Avatar answered Nov 06 '22 16:11

Minna