8

我展示了作为导航控制器的模态视图:

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

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

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

结果 黑屏

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

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

[[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"];
 }];

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

4

2 回答 2

3

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

于 2014-09-19T20:30:08.117 回答
3

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

[self dismissViewControllerAnimated:YES completion:nil];
于 2013-05-17T18:51:37.490 回答