JP Illanes
JP Illanes

Reputation: 3675

Fix Notification center orientation after the app resume execution

I have a view that is made to be displayed in landscape mode only, and is working well. But if you send the app to the background and then resume it, the notification center will appear in the orientation you had the device when resuming the app (usually portrait mode), so when I detect a swipe from left to right sometimes the notification center will appear. Any ideas how I can make the system know that it should show the notification center in landscape mode?

EDIT: The view displays in landscape mode as it should, the problem is only with the notification center.

Upvotes: 2

Views: 1281

Answers (2)

Kyle Howells
Kyle Howells

Reputation: 3551

Setting the status bar orientation sets the apps orientation. Alerts, NotificationCenter they all use the [UIApplication sharedApplication].statusbarOrientation as the orientation.

-(BOOL)shouldAutorotateToInterfaceOrientation should do it all for you but if, as you are saying, it isn't then you can set the orientation yourself.

Upvotes: 2

prince
prince

Reputation: 506

You can programmatically stop a portrait mode coming into play in the shouldAutorotateToInterfaceOrientation method, the following code is how you do that:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{

    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
        return YES;
    }
    else {
        return NO;
    }

}

Upvotes: 0

Related Questions