0

在用户从他们的照片库中选择一张图片后,我想关闭 imagePickerVierController 并呈现另一个,但得到错误:

警告:在演示或关闭过程中尝试从视图控制器中关闭!

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{
if (!self.submitPicturesDetailsViewController)
{
    self.submitPicturesDetailsViewController = [[SubmitPictureDetailsViewController alloc] initWithPicture: lPicture];
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
    [self.submitPicturesDetailsViewController setModalPresentationStyle:UIModalPresentationFormSheet];
    [self.popOver dismissPopoverAnimated:YES];
    [self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
}else
{
    //[self performSelector:@selector(present) withObject: nil afterDelay: 5.0];
    [self dismissViewControllerAnimated:NO completion:^{
        [self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
    }];
}
}

我努力了:

[self performSelector:@selector(present) withObject: nil afterDelay: 5.0];

它工作正常,所以显然完成块不能正常工作。

4

1 回答 1

0

我发现最好的万无一失的解决方案是递归调用我的方法,直到不再加载先前的视图控制器。

- (void) present
{
    if (!self.submitPicturesDetailsViewController.isViewLoaded) {
        [self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
    }else{
        [self performSelector:@selector(present) withObject: nil afterDelay: 0.1];
    }
}
于 2014-06-10T15:59:26.157 回答