【发布时间】:2012-01-31 05:07:02
【问题描述】:
我正在使用 ipad 模拟器测试 ipad 相机应用程序 我使用下面的代码,更改源类型而不是相机。
-(IBAction)useCamera:(id)sender{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate =(id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>) self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
newMedia = YES;
}
}
当它在模拟器中运行时,在 ios 5 模拟器中出现错误。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:'On iPad, UIImagePickerController must be presented via UIPopoverController'
但它在 4.3 模拟器上工作
【问题讨论】:
标签: ios ipad camera uiimagepickercontroller