锁定相机在ipad 2中用于横向模式

时间:2012-02-13 05:02:35

标签: iphone objective-c ios uiimagepickercontroller

尊敬的先生,              在这里,我使用uiimagepickercontroller打开相机并拍摄照片。但是我需要如何锁定uiimagepickercontroller的横向模式。我附上了一些线条代码

    UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init];
    imgPkr.delegate = self;
    imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera;
    imgPkr.cameraDevice=UIImagePickerControllerCameraDeviceFront;

    imgPkr.cameraOverlayView = anImageView;
    [theApp.TabViewControllerObject presentModalViewController:imgPkr animated:YES];
    [imgPkr release];

由于

2 个答案:

答案 0 :(得分:2)

子类UIImagePickerController,并覆盖此方法,如下所示:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

然后,不是创建一个UIImagePickerController,而是创建你所创建的类的对象(你可以命名它,例如UILandscapeImagePickerController),它只支持landscape。

答案 1 :(得分:1)

您无法控制UIImagePickerController

使用AVFoundation,您可以完全控制相机的处理

要使用AVFoundation,请查看此苹果示例

Link