Reputation: 197
In iOS6, How do i rotate UIAlertViews on top of a UIImagePicker when the device is in landscape mode? They are only loading up in portrait, but the app is landscape only. I had to manually rotate a custom cameraOverlayView (UIView), but i don't know how to do this with alerts?
Upvotes: 1
Views: 254
Reputation: 107121
For doing this, You need to subclass the UIImagePicker
class.
@interface yourImagePicker :UIImagePicker
{
}
@end
and you need to implement the shouldAutoRotate
method in the implementation and return only landscape mode
@implementation yourImagePicker
- (BOOL)shouldAutorotate
{
return [[UIDevice currentDevice] orientation] != UIInterfaceOrientationPortrait;
}
@end
And you need to create yourImagePicker
instance instead of UIImagePicker
Upvotes: 0
Reputation: 17364
The problem is that the UIImagePickerController supports only portrait mode:
From Apple Documentation The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.
So, when the picker is open, the device orientation is reported as portrait, and the UIAlertView are showed in portrait mode. Sure, using some "hack" you could rotate the UIAlertView, but the app will probably be rejected during the review.
The only "legal" way is to create your own image picker
Upvotes: 1