我可以使用相机和照片库在iPhone上选择照片。但是,同样的事情不适用于iPad。阅读几个教程,但我不确定出了什么问题。
@property (nonatomic, strong) UIPopoverController *popOver;
-(void)captureImage:(NSInteger)sourceType{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[self cameraUsingiPad];
return;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = sourceType;
picker.allowsEditing = YES;
[self presentViewController:picker animated:YES completion:nil];
}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;
}
}
-(void) cameraUsingiPad {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = NO;
self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
[self.popOver presentPopoverFromRect:self.view.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}