ios - dismissViewControllerAnimated 导致空屏幕

标签 ios objective-c ios6

我呈现模态视图,它是一个导航 Controller :

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

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

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

结果 Blank Screen

知道为什么会发生这种情况吗?

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

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

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

最佳答案

不确定这是导致黑屏的原因,但呈现的 View Controller 应该在自身上调用 dismissViewController,而不是在呈现的 View Controller 上。

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - dismissViewControllerAnimated 导致空屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16615941/

相关文章:

ios - UIAlertView 中的 UITextField : clear button is not centered vertically in iOS 6. 1

ios - UIView 适用于 iPhone 4in,但在 iPhone 3.5in 中被压扁

ios - ReactiveCocoa,在按钮启用时结合两个信号

ios - 我在 UITableView 中混合了静态和动态 UITableViewCells,并在 numberOfRowsInSection 中得到了错误的值

带有ARC的iOS APP没有泄漏但事件字节增加

ios - 没有获得正确的航点 GoogleMap Api

ios - 如何将我的旧应用程序更新到 iPhone 5?

iphone - 检测 iOS5 上何时禁用蓝牙

ios - iphone 再次拒绝启动请求

ios - swift 与 Objective-C : App performance