ios – dismissViewControllerAnimated结果为空屏幕

前端之家收集整理的这篇文章主要介绍了ios – dismissViewControllerAnimated结果为空屏幕前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我提出了一个模态视图,它是一个导航控制器:
  1. UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:photoEditVC];
  2. [self presentViewController:nvc animated:YES completion:NULL];

一旦我完成了模态视图,在nvc的可见控制器中:

  1. [self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];

结果

任何想法为什么会这样?

更新:
我意识到这只发生在解除视图之前,我更新共享单例类中的值,我用来跟踪事件.

  1. [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
  2. [self dismissViewControllerAnimated:YES completion:NULL];

但如果我这样做,它的工作正常:

  1. [[NSOperationQueue mainQueue] addOperationWithBlock:^{
  2. [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
  3. }];

或者我可以这样做,它也可以正常工作:

  1. [self dismissViewControllerAnimated:YES completion:^{
  2.  
  3. [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
  4. }];

当时,没有其他类观察者那个变量,所以我不明白为什么它会影响模态视图.

解决方法

不确定这是否会导致黑屏,但是呈现的视图控制器应该自己调用dismissViewController,而不是在呈现视图控制器上.
  1. [self dismissViewControllerAnimated:YES completion:nil];

猜你在找的iOS相关文章