gpt4 book ai didi

iphone - 带有动画的 popToRootViewController 然后切换选项卡

转载 作者:行者123 更新时间:2023-11-29 13:36:17 25 4
gpt4 key购买 nike

我有一个带有 4 个 View /选项卡的 UITabBarController。每个 View 都是一个 UINavigationController。

如何在其中一个 UINavigationController 上弹出 ToRootViewController 然后切换选项卡并将 viewController 推送到另一个使用动画的 UINavigationController?

所以顺序是:

一开始我们在 Tab 1 的 View 中,它是一个 UINavigationController。一个 View 已被推送到其根 ViewController 之外。

-Tab 1
- UINavigationController1
- RootViewController1
- SomeViewController1 [We are here]

-Tab 2
- UINavigationController2
- RootViewController2

点击 SomeViewController1 中的按钮会导致以下情况:

  1. UINavigationController1 弹出到它的 Root View Controller (带有动画)
  2. UITabBarController 将选项卡切换到 Tab2
  3. SomeViewController2 被推送到 UINavigationController2(带动画)

所以 View 看起来像这样:

-Tab 1
- UINavigationController1
- RootViewController1

-Tab 2
- UINavigationController2
- RootViewController2
- SomeViewController2 [We are here]

最佳答案

int tabYouWantToSelect=2;
BOOL isNavigation=YES;
[[self.tabBarController selectedViewController].navigationController popToRootViewControllerAnimated:YES];

//if any controller is presented as a model view then
//[[self.tabBarController selectedViewController] dismissModalViewControllerAnimated:YES];

[self.tabBarController setSelectedIndex:tabYouWantToSelect];

//the newly pushed view controller's viewWillAppear
-(void)viewWillAppear:(BOOL)animated {
if(isNavigation){
[self.navigationController pushViewController:objAddLocation animated:YES];
}
}

关于iphone - 带有动画的 popToRootViewController 然后切换选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10498724/

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