dismissViewControllerAnimated结果为空屏幕

时间:2013-05-17 18:47:07

标签: ios objective-c ios6

我提出了一个导航控制器的模态视图:

 UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:photoEditVC];
 [self  presentViewController:nvc animated:YES completion:NULL];

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

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

结果 Blank Screen

为什么会发生这种情况的任何想法?

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

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

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

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

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

[self dismissViewControllerAnimated:YES completion:^{

           [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
 }];

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

2 个答案:

答案 0 :(得分:3)

不确定这会导致黑屏,但是呈现的视图控制器应该自己调用dismissViewController,而不是在呈现视图控制器上。

[self dismissViewControllerAnimated:YES completion:nil];

答案 1 :(得分:3)

我在iOS 8 GM中看到了这个问题。将动画设置解除为NO就可以解决问题了。

相关问题