在UIImagePickerController中强制横向方向 [英] Force landscape orientation in UIImagePickerController

查看:139
本文介绍了在UIImagePickerController中强制横向方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手,我正在开发我的第一个应用程序。 (很抱歉,如果我问一个新手问题)

I'm new to iOS development, and Im developing my first app. (so sorry if Im asking a newbie question)

我的应用程序都是纵向的,除了我正在使用的地方 UIImagePickerController 拍照在该应用中使用,我在做什么是:

My app is all in portrait orientation, except to the place where I'm using UIImagePickerController to take a picture to be used in the app, what I'm doing is:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
picker.allowsEditing = NO;
[self presentModalViewController:picker animated:YES];

由于我的应用程序位于 Portrait ,我需要为 UIImagePickerController 仅限横向。如果我尝试使用:

As my app is in Portrait, I need to make something to the UIImagePickerController be in landscape only. if I try to use:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

似乎我无法使用,因为我的Xcode在这一行中识别为错误(可能因为Xcode的版本,我不确定)。而且我不确定,但似乎如果我正在开发 iOS 5.1 我需要为iOS 6.0实现 ,这是正确的吗?

It seems that I can't use, because my Xcode identify as a error in this lines (probably because of Xcode the version, I'm not sure). And I'm not sure, but it seems that if I'm developing for iOS 5.1 I will need to implement something for iOS 6.0 too, is it correct?

有人可以帮助我理解制作这个 UIImagePickerController 需要什么,只有应用程序中的这个视图控制器才能在横向工作并且可以工作iOS 5.1和6?

Can someone help me to understand what is need to make this UIImagePickerController, and only this view controller in the app, work in Landscape orientation and works in iOS 5.1 and 6?

问候

推荐答案

按照< a href =http://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/doc/uid/TP40007070-CH3-DontLinkElementID_1\"rel =noreferrer > UIImagePickerController类参考

重要:该的UIImagePickerController class仅支持纵向模式。此类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改,但有一个例外。您可以将自定义视图分配给 cameraOverlayView 属性并使用该视图显示其他信息或管理相机界面与代码之间的交互。

Important: 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.

所以看起来强制横向模式不受支持和阻止,除非你通过用自定义 cameraOverlayView 替换默认控件来实现。

So it looks like forcing landscape mode is unsupported and discouraged, unless you do so by replacing the default controls with a custom cameraOverlayView.

这篇关于在UIImagePickerController中强制横向方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆