这似乎是一个简单的问题,我已经看到类似问题的答案,但答案不起作用(至少不再起作用)。我在 viewDidAppear
中有以下代码:
UIImagePickerController *imagePicker;
imagePicker =[[UIImagePickerController alloc] init];
imagePicker.allowsEditing = YES;
{imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;}
imagePicker.delegate=self;
NSLog(@"ViewDidAppear");
[self presentModalViewController:imagePicker animated:YES];
NSLog (@"Modal Window Displayed.");}
这允许用户从图像库中选择图像,这是有效的。一旦选择了该图像,就会调用 didFinishPickingMediaWithInfo,其顶部有以下代码:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
NSLog(@"Image Is Picked");
[[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
[self dismissModalViewControllerAnimated:YES];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self dismissViewControllerAnimated:NO completion:nil];
[self.navigationController popViewControllerAnimated:YES];
如您所见,我尝试了 StackOverflow 上找到的几种不同方法来使其发挥作用。他们都被忽视了。没有错误,只是什么也没发生;选择器 View 永远不会消失。是什么赋予了?我正在使用 xCode 7.2.1。
我的代码中有一个类似的地方,我在其中呈现了另一个模态视图,但也无法摆脱它。
最佳答案
问题是 didFinishPickingMediaWithInfo 方法实际上并没有关闭另一个 View ,直到它执行完成(即使在该方法中运行的内容需要将近一分钟!)。当该方法完成时,我已经模态地呈现了另一个 View Controller 。我一直在尝试的几乎所有技术实际上仍然有效。
关于ios - 现在不可能从 didFinishPickingMediaWithInfo 方法中关闭图像选择器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36216081/