How can I programmatically check whether the device orientation is locked in iOS? I see nothing in UIDevice. I know that this is supposed to be transparent to the app. But I
There's no way how to detect if orientation is locked or not. YouTube app doesn't lock to landscape, it just displays movie in landscape orientation, but when you rotate your iPhone, movie rotates as well (if there's no orientation lock).
IOW orientation lock is handled by system, transparent to your application.
If you want to achieve this functionality - just display your view in landscape mode even if the iPhone is in portrait mode and later enable rotation of your view. It will behave in the same way as YouTube app.
Update for comment:
.h
BOOL rotationEnabled;
.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return rotationEnabled || ( toInterfaceOrientation == UIInterfaceOrientationLandscapeRight );
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
rotationEnabled = YES;
}