ios - 现在不可能从 didFinishPickingMediaWithInfo 方法中关闭图像选择器吗?

标签 ios objective-c xcode7

这似乎是一个简单的问题,我已经看到类似问题的答案,但答案不起作用(至少不再起作用)。我在 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/

相关文章:

ios - 将 startMonitoringSignificantLocationChanges 与 NSTimer 结合使用以提高电池使用率

objective-c - 如何更改自定义 NSTextfield 的绘制矩形内的文本颜色

swift - 解析查询 findObjectsInBackgroundWithBlock 时出错

ios - View Controller 没有填满屏幕 Xcode

屏幕锁定时javascript setInterval暂停(IOS)

ios - 我怎样才能从这个字符串中得到一个 NSDate,这个 NSDate 到 long 或 NSTimeInterval

ios - 如何使 UITableView 分隔符插图从屏幕边缘移开?

ios - 删除 subview 并将其添加到自定义 UITableViewCell

iphone - 使用 iPhone 的排序描述符对核心数据位置变化进行排序

ios - swift/iOS : Data takes a few seconds to load when screen appears