通过照片库中的UIImagePickerController接口选择图片后,即使我在imagePickerController中调用dismissModelViewControllerAnimated:didFinishPickingImage:editingInfo,照片库视图也会保持显示状态.
有没有人见过这个?这些是我正在使用的三种相关方法:
- (IBAction)choosePictureFromLibrary:(id)sender { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { UIImagePickerController* picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsImageEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:picker animated:YES]; [picker release]; } else { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error accessing Photo Library" message:@"This device does not support a Photo Library." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } } - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Picture picked!" message:@"You picked a picture!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; [picker dismissModalViewControllerAnimated:YES]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker { [picker dismissModalViewControllerAnimated:YES]; }
我原本以为调用imagePickerController:didFinishPickingImage:editingInfo会完全关闭Photo Library视图,但似乎没有.还有什么我必须做才能让它消失吗?
您需要访问选择器的viewController而不是选择器本身.请尝试使用此行.
[[picker parentViewController] dismissModalViewControllerAnimated:YES];