我尝试了各种关闭 UIImagePickerController 的方法,但没有任何运气。我究竟做错了什么。
- (IBAction)choosePhoto
{
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.picker animated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
{
NSLog(@"dismiss image picker");
[self dismissModalViewControllerAnimated:NO];
[[self.picker parentViewController] dismissModalViewControllerAnimated:NO];
[self.presentedViewController dismissModalViewControllerAnimated:NO];
[self.presentingViewController dismissModalViewControllerAnimated:NO];
// And every other way i could think of
}
- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
.. same stuff here
}
我试图呈现来自父级、祖级、navigationController 和根控制器的选择器,但没有任何效果。无论我做什么,我都不能忽略 ImagePickerController。
请注意,每次都会调用日志语句。
Cheers
试试这条线。它可能对你有用。
[self.picker dismissModalViewControllerAnimated:NO];
And for iOS 6稍后使用这个
[self.picker dismissViewControllerAnimated:NO completion:nil];
还可以使用此代码来展示您的选择器控制器
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
[self presentViewController:self.picker animated:YES completion:nil];
} else {
//To target iOS 5.0
[self presentModalViewController:self.picker animated:YES];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)