[英]how to capture avfoundation in landscape mode instead of portrait mode
[英]How to show UIImagePickerControllerSourceTypeCamera in Landscape instead of Portrait
我正在使用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];
}
我的问题是,当我处于横向模式时,如果我单击按钮。 相机以人像模式显示(图像以反向模式显示)。 但是,如果我摇晃iPad,它将显示在LandScape中。
对于ios6中的方向,我正在使用以下方法,但是我没有写任何与UIImagePickerControllerSourceTypeCamera相关的内容
- (void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
{
}
else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
{
}
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait;
}
你不应该这样做。 Apple文档摘录:
重要提示 :UIImagePickerController类仅支持纵向模式。 该类旨在按原样使用,不支持子类化。 此类的视图层次结构是私有的,除了一个例外,不得修改。 您可以将自定义视图分配给cameraOverlayView属性,并使用该视图显示其他信息或管理摄像头界面与您的代码之间的交互。
它在这里: http : //developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.