【发布时间】:2015-09-24 06:29:07
【问题描述】:
我正在开发通用应用程序并想打开相机。现在我可以在 iphone 上使用 UIimagePickerController 打开相机,但在 iPad 上它不起作用。我已经搜索了解决方案并找到了此代码
self.cameraController = [[UIImagePickerController alloc] init];
self.cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraController.modalPresentationStyle = UIModalPresentationCurrentContext;
self.cameraController.showsCameraControls = NO;
self.cameraController.navigationBarHidden = YES;
self.cameraController.wantsFullScreenLayout = NO;
[self.cameraController setCameraOverlayView:ar_overlayView];
[ar_overlayView setFrame:self.cameraController.view.bounds];
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self presentViewController:self.cameraController animated:YES completion:nil];
}];
}
else{
[vc presentViewController:self.cameraController animated:YES completion:nil];
}
还遵循了一些教程,例如
TechnoTopia Post 但没有找到任何运气。我已经在 iphone 5s 上对其进行了测试,并且在其中运行良好,但在 iPad mini 上,相机没有显示。任何帮助将不胜感激!
【问题讨论】:
-
@gansai 不,它不是重复的,请在标记为重复之前阅读这两个问题。你提到的问题是关于前置摄像头的,这个问题是关于开放式摄像头的。
-
它不重复任何问题,因为我在打开相机而不是前置相机时遇到问题。
标签: ios iphone ipad uiimagepickercontroller