我正在测试ipad相机应用程序与ipad模拟器 我使用下面的代码,更改源类型而不是相机。测试ipad 2相机与xcode模拟器IOS 5
-(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'
但随着iOS5的其对4.3模拟器
谢谢,有在第2行的警告它是确定如果我使用imagePicker.delegate =(ID)自我; –
Susitha
2012-01-31 06:34:52