在解雇另一个之后呈现模态视图控制器

时间:2014-02-22 03:53:50

标签: ios objective-c uiviewcontroller presentviewcontroller

当用户从他们的照片库中选择一张照片后,我想要关闭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];

它工作正常所以显然完成块无法正常工作。

1 个答案:

答案 0 :(得分: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];
    }
}