Reputation: 86075
I'm trying to notify my UIViewController
re-apply layout by device orientation. To do this, I'm posting UIDeviceOrientationDidChangeNotification
to default center. It worked, but without rotation animation. I think there is something I had missing. How can I post UIDeviceOrientationDidChangeNotification
properly?
Upvotes: 1
Views: 1353
Reputation: 4225
It will post events for you:
- (void)updateOrientation
{
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
But, of course, you should be more neat and call [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]
when you need to stop rotations, and then you call [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
when you are ready to handle it again: it will call all necessary callbacks for your view controller.
Upvotes: 1
Reputation: 8526
Use:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:YES];
instead (replace LandscapeRight as needed), as you should not be posting system notifications.
Upvotes: 1
Reputation: 2044
I don't think there should be anything when you try to post that. Instead, it is posted automatically when there is an orientation change. You should be adding a observer for hat notification if you want to use it.
Upvotes: 0