等到popToRootViewControllerAnimated:YES动画完成

pdr*_*rod 3 animation cocoa-touch uinavigationcontroller ios

我有一个基于菜单的导航.菜单是tableView.每当用户按下该表中的一个条目时,我想切换到另一个视图控制器,如果有任何视图被推送,我想先清理导航堆栈.

这就是我在做的事情

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [(UINavigationController *)self.tabBar.selectedViewController popToRootViewControllerAnimated:YES];


    self.tabBar.selectedIndex = indexPath.row;

}
Run Code Online (Sandbox Code Playgroud)

    self.tabBar.selectedIndex = indexPath.row;
Run Code Online (Sandbox Code Playgroud)

不要让popToRoot动画完成.有没有办法知道动画何时完成?

谢谢

Guo*_*uan 5

在rootViewController中,当rootViewController调用- (void)viewDidAppear:(BOOL)animated它时,表示动画已完成.

您可以在rootViewControllers中进行编码 - (void)viewDidAppear:(BOOL)animated

如果你想在当前的ViewController中编写代码,我认为它有两种方式:

delegate1.add a 在rootViewController中,当调用- (void)viewDidAppear:(BOOL)animateduse delegate发送消息时

2.在调用- (void)viewDidAppear:(BOOL)animated发布通知时,在rootViewController中添加通知.在您当前的ViewController中,您可以收到通知