Fix notification center orientation after resuming application

I have a view that should only display in landscape mode and works well. But if you send the app to the background and then resume it, the notification center will appear in the orientation that you had when resuming the application (usually in portrait mode), so when I detect scrolling 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 is displayed in landscape mode, as it should be, the problem is only associated with the notification center.

+2
source share
2 answers

Setting the orientation of the status bar sets the orientation of the applications. Alerts, NotificationCenter They all use [UIApplication sharedApplication] .statusbarOrientation as an orientation.

- (BOOL) shouldAutorotateToInterfaceOrientation should do all this for you, but if, as you say, this does not mean that you can set the orientation yourself.

+2
source

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

  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){ return YES; } else { return NO; } } 
0
source

Source: https://habr.com/ru/post/919311/


All Articles