我有一個基於菜單的導航。該菜單是一個tableView。每當用戶按下該表中的一個條目時,我想切換到另一個視圖控制器,並且如果有推送的任何視圖,我想首先清理導航堆棧。等到popToRootViewControllerAnimated:YES動畫完成
這是我在做什麼
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[(UINavigationController *)self.tabBar.selectedViewController popToRootViewControllerAnimated:YES];
self.tabBar.selectedIndex = indexPath.row;
}
但
self.tabBar.selectedIndex = indexPath.row;
不要讓popToRoot動畫完成。有什麼方法可以知道動畫何時完成?
感謝
這是不可預知的,我 - 當我推了該塊多以後執行新視圖控制器 – diachedelic
塊應該在CATransaction結束時執行,並且除rootViewController之外的所有控制器都會彈出。你可以嘗試另一種轉變嗎?例如使用[self.navigationController popViewControllerAnimated:YES];而不是popToRootViewControllerAnimated,或嘗試沒有動畫。 – buttcmd