ios - 运行 iOS 8.2 的 ipad 中不显示相机

标签 ios iphone ipad uiimagepickercontroller

我正在开发通用应用程序,想打开相机。现在我可以在 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 上相机没有出现。任何帮助将不胜感激!

最佳答案

在 iPad 上试试这个

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex==0)
{
     [[NSOperationQueue mainQueue] addOperationWithBlock:^{
 UIImagePickerController* picker=[[UIImagePickerController alloc]init];
    picker.delegate=self;
    picker.allowsEditing=YES;
    picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:picker animated:YES completion:nil];
     }];
}
else if (buttonIndex==1)
{
     [[NSOperationQueue mainQueue] addOperationWithBlock:^{
 UIImagePickerController* picker=[[UIImagePickerController alloc]init];
    picker.delegate=self;
    picker.allowsEditing=YES;
    picker.sourceType=UIImagePickerControllerSourceTypeCamera;
         [self presentViewController:picker animated:YES completion:nil];}];
}
}

关于ios - 运行 iOS 8.2 的 ipad 中不显示相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32754754/

相关文章:

ios - iPad 照片库框架

iphone - 如何使用 pinch zoom(UIPinchGestureRecognizer) 更改 UITextView 的宽度?

iphone - 在 facebook 照片 api 上分享新的 IOS

ios - iOS重命名项目

ios - 非可选代表的弱与无主

objective-c - 获取 Coretext 中的可见字符串范围,而无需在 iOS 上渲染文本

iphone - Indexed UITableView 的部分索引标题不正确的奇怪问题

iphone - [NSManagedObjectContext save :] 上出现 NSManagedObjectMergeError 错误的原因

ios - 如何通过多个目标使用同名的不同 Assets

iphone - UIWebView Fontsize 和 UItextView Fontsize 之间的区别