我正在測試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