在尝试呈现联系人编辑器VC时,我收到错误消息
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];
我认为这可以帮到你
答案 1 :(得分:0)
我认为你在动画中同时呈现两个VC。 在呈现或解除时将VC的一个动画设置为NO,并查看警告是否消失。
我不是100%肯定,但是如果你想要两个动画,你应该在第一个完成块上运行第二个动画,或者使用计时器来延迟第二个视图控制器的导航开始。