dismissViewControllerAnimated结果为空屏幕

Ale*_*x L 8 objective-c ios ios6

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

 UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:photoEditVC];
 [self  presentViewController:nvc animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)

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

[self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)

结果 黑屏

任何想法为什么会这样?

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

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

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

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

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

[self dismissViewControllerAnimated:YES completion:^{

           [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
 }];
Run Code Online (Sandbox Code Playgroud)

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

Sea*_*dek 3

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

[self dismissViewControllerAnimated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)