gpt4 book ai didi

iphone - 如何以编程方式切换到 UITabBarController 中的另一个选项卡?

转载 作者:可可西里 更新时间:2023-11-01 06:18:35 25 4
gpt4 key购买 nike

我有一个 UITableView,我想在单击 UITableView 中的一个单元格时切换到另一个选项卡。

我已经试过了,但是不行

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

MainView *mainView = [[MainView alloc] initWithNibName:@"MainView" bundle:nil];
mainView.tabBarController.selectedIndex = 3;

}

最佳答案

每次选择一行时,您都会加载 MainView 的新副本。这些新副本不会在任何地方显示。您需要访问现有的、显示的主视图实例的选项卡栏 Controller 。也许这会起作用:

self.tabBarController.selectedIndex = 3;

关于iphone - 如何以编程方式切换到 UITabBarController 中的另一个选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7862530/

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