如何在Landscape而不是Portrait中显示UIImagePickerControllerSourceTypeCamera

时间:2013-03-20 10:58:30

标签: iphone ios objective-c uiimagepickercontroller uiinterfaceorientation

我正在使用iPad应用程序,当我们点击右边的按钮时,我正在执行如下操作:

    -(IBAction)camerabuttonAction:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
   picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.delegate = self;

    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:picker];
   [self.popoverController presentPopoverFromRect:CGRectMake(50, -250, 500, 300) inView:appDelegate.splitview.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

我的问题是,当我在Land scape模式时,如果我点击按钮。相机以纵向模式显示(图像以反向模式显示)。但是,如果我摇动iPad,它会在LandScape中显示。

对于ios6中的Orientation我正在使用下面的方法,但我没有写任何与UIImagePickerControllerSourceTypeCamera有关的内容

    - (void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
    {
}
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
    {
}

}

    -(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait;
}

1 个答案:

答案 0 :(得分:3)

你不应该这样做。摘自Apple文档:

  

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

就在这里:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html