解散和代表UIImagePickerController摄像头iOS8.4的问题

编辑问题从零开始恢复。

我有一个ViewController A有一个导航栏button,它呈现了一个UIImagePickerControllertypes的UIImagePickerControllerSourceTypeCamera ,我们将调用这个ViewController B.AdidFinishPickingMediaWithInfo:方法中,我将呈现ViewController C.

现在问题从这里开始。 当我终于到达C时 ,我们可以看到视图堆栈显然是:

A -modal-> B -modal-> C

C我然后有一个“后退”button出现在导航栏应该带我回到B. 但是,由于B是一个UIImagePickerController,我不能重用它,它必须被解雇。 所以,要做到这一点,我目前有以下方法执行C :上的“返回”button:

 - (IBAction)backOnPost:(UIBarButtonItem *)sender { [self.view endEditing:YES]; UINavigationController *LogControl = [self.storyboard instantiateViewControllerWithIdentifier:@"LogControl"]; RGLogViewController *logView = (RGLogViewController *)LogControl.topViewController; [UIView animateWithDuration:0.25 animations:^{ self.presentingViewController.view.alpha = 0; [self.presentingViewController dismissViewControllerAnimated:NO completion:nil]; [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil]; } completion:^(BOOL finished){ [logView setBoolBackPushed]; }]; } 

上面的代码的工作原理是通过驳回BC来让我回到A. 但是,由于解雇了两个ViewController,还是有一些“黑屏”,你仍然可以看到转换。 你可以在完成块中看到[logView setBoolBackPushed]; ,这将静态BOOLvariables设置为true,以便AviewWillAppear:的开始viewWillAppear:立即呈现一个新的UIImagePickerController – 方法如下所示:

 - (void)viewWillAppear:(BOOL)animated { NSLog(@"HERES postBackButtonPushed:%hhd", postBackButtonPushed); if(postBackButtonPushed == true) { self.view.hidden = YES; self.navigationController.navigationBar.hidden = YES; self.tabBarController.tabBar.hidden = YES; UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init]; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.delegate = self; [self presentViewController:imagePicker animated:NO completion:^{}]; } 

这是目前我如何获得以下预期的效果:从A到相机( B ),到C ,然后回到一个新的相机,这是我们的新B。 这是实现了几乎完美的无缝过渡。

我仍然有能够稍微看到过渡的问题。 另一个问题是时机。 解雇和呈现ViewControllers的这种合作需要比我想要的更多的时间。 这几乎是瞬间的,但我想要更好的东西。 我该怎么做,我做错了什么?

有一些可能的情况导致你的问题:

  1. 在A之后呈现B,然后呈现C对于UX / UI和代码来说都有点奇怪。 或者从A推B,然后在B上提出C或者驳回A,提出B,解雇B,提出C.

  2. 有完成的方法,你没有使用它们。 你的代码显示你调用dismissViewControllerAnimated两次C和B为前。 你应该处理提交和解雇命令。 我认为iOS 8.2+或8.3+开始更有效地处理它们。 如果出现错误,则会在此版本之后崩溃。

  3. imagepicker控制器会导致此错误,同时以不同的方式closuresVC。 例如。 在呈现VC之前显示警报popup可能会导致崩溃。

我相信这会为你工作。 做!

  [self.presentingViewController dismissViewControllerAnimated:NO completion:^{ [RefrenceOfPreviousViewController dismissViewControllerAnimated:YES completion:^{ }]; }]; 

代替

  [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];