2014-02-22 82 views
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]; 

而且它正常工作,從而明顯地完成模塊不能正常工作。

+0

檢查這裏的答案,回答了類似的問題在這裏, http://stackoverflow.com/a/3919894/2458651 – zaheer

+0

@zaheer這個答案是從2010年,是一個不同的API。自iOS5以來,一個完成塊被傳遞給一個新的API,允許鏈接動畫。上面的代碼**應該**工作,但不。 –

+0

我自己通過創建一個虛擬項目來檢查它。有效。找不到此類問題的原因。我認爲你唯一的選擇是以0.1秒的延遲調用選擇器。 – santhu

回答

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]; 
    } 
}