我有一个 UITabBarController,它是 UINavigationBarController 中的第二项。 UITabBarController 中有几个 View ,其中一个是名为 AccountViewController 的 UIViewController 子类。明白了吗?
Login View Controller -> UIViewController + UITabBarController - > Account View Tab -> Button
我想使用按钮 - 注销 - 弹回到登录 View 。我该怎么做?
最佳答案
假设您正在其中一个 UIViewControllers
中创建 UITabBarController
,这些 UIViewControllers
是您所在的 UINavigationController
中 View Controller 字符串的一部分做了类似的事情:
UITabBarController *mytabs = [[UITabBarController alloc] init];
[self.view addSubview:mytabs.view];
mytabs.delegate = self; // This is key to getting back your UINavigationController
您可以从添加到 mytabs.viewControllers
数组的 UIViewControllers
之一中调用此函数,如下所示:
[[(UIViewController *)self.tabBarController.delegate navigationController] popViewControllerAnimated:YES];
您还可以指定是否希望它转到 UINavigationController 堆栈中的特定 viewController 索引(以防万一您的登录 viewController 不是下一个或 Root View Controller )。
关于objective-c - 在选项卡栏和导航栏内弹出 View 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7636183/