gpt4 book ai didi

ios - UIViewController 到 UITabBarController

转载 作者:行者123 更新时间:2023-12-01 16:36:47 24 4
gpt4 key购买 nike

我有一个名为 LoginViewController 的 View Controller 其类型为 UIVewController.用户登录后,我想将该 View 传输到由 FirstViewController 组成的 UITabBarController和 SecondViewController.
我尝试使用以下方法来做到这一点:

- (void)switchView {
FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:firstView animated:YES];
}

但这似乎不起作用。是不是因为我没有考虑整个 UITabBarController?

最佳答案

是的,你应该显示 UITabBarController:

- (void)switchView {
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
UITabBarController *tabController = [[UITabBarController alloc] init];
tabController.viewControllers = @[firstViewController, secondViewController];
[self presentViewController:tabController animated:YES completion:nil];
}

关于ios - UIViewController 到 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27511639/

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