我正在实现一种级联菜单。
在我的故事板中,我UINavigationController
有一个UIViewController
作为根视图控制器的(假设它是一个MyViewController
)。MyViewController
有一个情节提要 ID:“菜单”。
由于此控制器是一个菜单,因此它显示一个 tableView。单击单元格时,会触发一些代码,尤其是:
UINavigationController *menuNavigator = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
MyViewController *newMenu = (MyViewController*)menuNavigator.topViewController;
//Some configurations of newMenu
[self.navigationController pushViewController:newMenu animated:YES];
因为这里一切正常。
在子菜单中,最后一个单元格是“后退”单元格。当用户触摸它时,它会触发代码:
[self.navigationController popViewControllerAnimated:YES];
我在上一个菜单上正确返回,但没有动画。
我也试过:
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
但我仍然没有动画。
在情节提要上,我的导航控制器设置为不显示导航栏。如果我显示它,然后触摸自动出现的“后退”按钮,结果是一样的:没有动画。
我的代码有什么问题?
编辑
我正在使用 Autolayout 和 ARC;