gpt4 book ai didi

iphone - 从 UINavigationControllerDelegate 内部获取当前 View Controller

转载 作者:行者123 更新时间:2023-12-03 20:16:03 25 4
gpt4 key购买 nike

有没有办法让 View Controller 从内部转换出来:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

当我使用navigationController.topViewController时,我得到了我要进入的那个。使用 navigationController.viewControllers 就足够了,以防我深入导航系统(因为我可以在数组内查找上一个 Controller ),但如果我移动到“外部”,这将不会不行,难道我需要的 View Controller 已经不存在了。

有什么通用的方法吗?我需要它,这样我就可以在动画期间添加一个 subview ,然后它当然就消失了。

谢谢

最佳答案

如果你想从导航 Controller 数组中找到特定的ViewController,那么试试这个.........

for(UIViewController * VC in [self.navigationController viewControllers])
{
if([VC isKindOfClass:[ViewController class]])
{
//YOUR CODE .......
}
}

享受编码......

关于iphone - 从 UINavigationControllerDelegate 内部获取当前 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6403238/

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