我的相机视图中存在问题,从iPad拍摄时无法打开。当点击相机按钮它什么也没做,请任何人帮助我。我使用的是xcode 6.4和安装在iPad上的操作系统是8.4.1
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Camera Unavailable"
message:@"Unable to find a camera on your device."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
alert = nil;
}
答案 0 :(得分:0)
试试这段代码。
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSMutableArray *mediaTypes = [[NSMutableArray alloc] init];
[mediaTypes addObject:(__bridge NSString *)kUTTypeImage];
picker.mediaTypes = mediaTypes;
picker.delegate = self;
[self presentViewController:picker animated:YES completion:NULL];
}
将MobileCoreServices添加到您的框架中。