简体   繁体   English

如何在横向而不是纵向中显示UIImagePickerControllerSourceTypeCamera

[英]How to show UIImagePickerControllerSourceTypeCamera in Landscape instead of Portrait

I am working on iPad App, There when we click the right bar button i am giving an action like below: 我正在使用iPad App,当我们单击右栏按钮时,我正在执行以下操作:

    -(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];
}

My problem is, When i am in Land scape mode if i click the button. 我的问题是,当我处于横向模式时,如果我单击按钮。 The camera show in portrait mode(Image appears in reverse mode to see). 相机以人像模式显示(图像以反向模式显示)。 But, if i shake the iPad then it shows in LandScape. 但是,如果我摇晃iPad,它将显示在LandScape中。

For Orientation in ios6 i am using below method, But i did not write anything related to UIImagePickerControllerSourceTypeCamera 对于ios6中的方向,我正在使用以下方法,但是我没有写任何与UIImagePickerControllerSourceTypeCamera相关的内容

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

}

    -(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait;
}

You shouldn't do this. 你不应该这样做。 Extract from Apple Documentation: Apple文档摘录:

Important : The UIImagePickerController class supports portrait mode only. 重要提示 :UIImagePickerController类仅支持纵向模式。 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属性,并使用该视图显示其他信息或管理摄像头界面与您的代码之间的交互。

It's here : http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html 它在这里: http : //developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM