1

我有 2 个视图控制器。FirstViewControllerSecondViewController。二是通过presentViewController...

两者都在收听通知:

第一视图控制器.m

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

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

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

    }
}

第二视图控制器.m

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

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

        // The user decided not to log in

        [self dismissViewControllerAnimated:YES completion:^{

        }];
    }
}

SecondViewController解雇并FirstViewController重新加载表。但是我收到了我不喜欢的警告

警告:在演示或关闭过程中尝试从视图控制器中关闭!

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

4

1 回答 1

0

如果在动画使其首先出现之前被SecondViewController调用解除,则可能会发生此警告。(void)facebookUpdated:(NSNotification *)notification

你可以:

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