gpt4 book ai didi

ios - 等到 popToRootViewControllerAnimated :YES animation is done

转载 作者:可可西里 更新时间:2023-11-01 17:09:14 26 4
gpt4 key购买 nike

我有一个基于菜单的导航。菜单是一个tableView。每次用户按下该表中的一个条目时,我想切换到另一个 View Controller ,如果有任何 View 被推送,我想先清理导航堆栈。

这就是我做的

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

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


self.tabBar.selectedIndex = indexPath.row;

}

但是

    self.tabBar.selectedIndex = indexPath.row;

不要让 popToRoot 动画结束。有什么方法可以知道动画何时完成?

谢谢

最佳答案

在您的 rootViewController 中,当您 rootViewController 调用 - (void)viewDidAppear:(BOOL)animated 时,这意味着动画已完成。

您可以在 rootViewControllers - (void)viewDidAppear:(BOOL)animated

中编写代码

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

1.在rootViewController中添加一个delegate,当调用- (void)viewDidAppear:(BOOL)animated时使用delegate发送消息

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

关于ios - 等到 popToRootViewControllerAnimated :YES animation is done,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14725317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com