2014-04-26 56 views
0

雖然試圖呈現聯繫人編輯器VC,我得到的警告:試圖提出<UINavigationController的同時演示正在進行

Warning: Attempt to present <UINavigationController: 0x15fe273f0> on <UINavigationController: 0x15fe0e730> while a presentation is in progress!

的錯誤信息,我相信這是因爲我的UIImagePickerController仍然有效。

這裏是我的didFinish方法

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

    UIImage *image = info[UIImagePickerControllerOriginalImage]; 
animated:YES]; 
    [picker dismissViewControllerAnimated:YES completion:NULL]; 
    [self scanWithImage:image]; 

} 

正如你可以看到第二個消息應該駁回VC,但它沒有,和它保持,直到應用程序的執行結束。

scanWithImage:最終調用showNewPersonViewController這裏是方法:

-(void)showNewPersonViewController 
{ 
    ABNewPersonViewController *picker = [[ABNewPersonViewController alloc] init]; 
    picker.displayedPerson = _person; 
    picker.newPersonViewDelegate = self; 

    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:picker]; 
    // Change status bar back to black due to white contact creation. 
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; 

    [self presentViewController:navigation animated:YES completion:nil]; 
} 

在該方法中,我得到錯誤信息的最後一行,然後應用程序完成它的執行,並返回到主VC。

如何避免這種情況並正確顯示聯繫人創建VC?

+0

如何呈現圖像採集控制器? –

回答

0

讓我們試試:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    UIImage *image = info[UIImagePickerControllerOriginalImage]; 
    // I think picker should change to self == this class dismisses, not picker dismisses 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

// should implement [self scanWithImage:image]; in parent class which contains VC has pickerView. 
// Because after dismissing, VC which contains picker is dealloc, how can you call [self presentViewController:navigation animated:YES completion:nil]; 

,我認爲這可以幫助你

0

,我認爲你是在同一時間與動畫呈現兩名風險投資。 在呈現或解散時將VC的動畫之一設置爲NO,並查看警告是否消失。

我不是100%確定,但如果你想要兩個動畫,你應該運行第一個完成塊的第二個或使用計時器來延遲第二個視圖控制器的導航開始。

相關問題