【问题标题】:Warning: Attempt to dismiss from view controller (UINavigationController) while a presentation or dismiss is in progress警告:在演示或关闭过程中尝试从视图控制器 (UINavigationController) 关闭
【发布时间】:2013-07-16 18:02:13
【问题描述】:

我有 2 个视图控制器。 FirstViewControllerSecondViewController。第二种通过presentViewController...呈现

两者都在收听通知:

FirstViewController.m

- (void)facebookUpdated:(NSNotification *)notification {

    if (![[FacebookHelper sharedInstance] isLoggedIn]) {

        [self.addReminderTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, 2)] withRowAnimation:UITableViewRowAnimationFade];

    }
}

SecondViewController.m

- (void)facebookUpdated:(NSNotification *)notification {

    if (![[FacebookHelper sharedInstance] isLoggedIn]) {

        // The user decided not to log in

        [self dismissViewControllerAnimated:YES completion:^{

        }];
    }
}

SecondViewController 被解除,FirstViewController 中的表被重新加载。但是我收到了这个我不喜欢的警告

警告:尝试从视图控制器中关闭 当演示或解雇是 进行中!

而且我真的不确定我为什么会得到它。我确信没有其他解雇正在进行中。我不确定正在进行的演示是什么意思?

【问题讨论】:

    标签: objective-c cocoa-touch uiviewcontroller nsnotification


    【解决方案1】:

    如果在动画完成之前调用(void)facebookUpdated:(NSNotification *)notification 解除了SecondViewController,则会出现此警告。

    你可以:

    1. 忽略警告
    2. 如果 SecondViewController 可能会立即被关闭,则不要为它的显示设置动画来避免它。
    3. 通过在初始视图控制器动画上设置回调来避免它,同时仍然允许动画,该回调调用第二个视图控制器上的函数,告诉它动画已经完成。然后您可以在调用dismissViewControllerAnimated 之前检查(void)facebookUpdated:(NSNotification *)notification 中的此属性,如果加载尚未完成,请设置另一个标志以使原始动画回调函数调用dismissViewControllerAnimated(这可能是最正确的解决方案,但也是最复杂的。)

    【讨论】:

      猜你喜欢
      • 2013-06-28
      • 2015-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 2017-01-15
      • 1970-01-01
      相关资源
      最近更新 更多