iOS-Navigationcontroller堆栈问题
从根视图导航堆栈获取tabBarController。当我从tabBar controller获取selectedcontroller时,应用程序崩溃iOS-Navigationcontroller堆栈问题,ios,objective-c,uitabbarcontroller,Ios,Objective C,Uitabbarcontroller,从根视图导航堆栈获取tabBarController。当我从tabBar controller获取selectedcontroller时,应用程序崩溃 TabController *TabBar = (TabController *)viewController.navigationController.presentedViewController; UINavigationController *selectedNCinTab = (UINavigationController *)Tab
TabController *TabBar = (TabController *)viewController.navigationController.presentedViewController;
UINavigationController *selectedNCinTab = (UINavigationController *)TabBar.selectedViewController;
当执行上面的行时会崩溃。理由如下
-[UINavigationController selectedViewController]:发送到实例0xf4b0be0的无法识别的选择器
您可能需要访问navigationController.topViewController,而不是第1行中的presentedViewControllertry(UINavigationController*)(TabBar.selectedViewController)是否获取选项卡栏的对象?尝试在控制台中打印它。它是你创建的同一个对象吗?是的,我正在获取tabbar实例。。。