开发者

Require landscape photo on iPhone

Is there an easy way to force the iPhone to take a photo in landscape and not allow portrait orientation? The app will be in portrait, but when the camera launches, I'd like it to be in landscape and not allow th开发者_StackOverflowe user to take a portrait photo.


I dont think you can really do this; you could try to place an overlay on the UIWindow that tells the user to hold their phone in landscape mode. Then remove the view if the user holds their phone the correct way, and vice versa.


Just found a simple way (tested on iOS 6). With this code, the interface will never rotate to portrait, only landscape. Thus:

you're sure to have a landscape picture

the interface clearly shows to the user that it's landscape only

Sample code:

@implementation UIImagePickerController (noRotation)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation /* iOS 5 */
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations /* iOS 6 */
{
    return UIInterfaceOrientationMaskLandscape;
}

@end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜