gpt4 book ai didi

iphone - 在 Xcode 中以编程方式按下 UITabBar 按钮

转载 作者:太空狗 更新时间:2023-10-30 03:21:09 24 4
gpt4 key购买 nike

抱歉新手问题。我的主窗口 View 中有一个 UITabBar,每个选项卡都有一个 UINavigationController 数组。该结构类似于 iPod 应用程序,因为可以通过选择 TabBar 项来查看主视图,然后用户可以通过将 View 推送到堆栈来使用 NavigationController 进一步下钻。

我希望能够做的是相当于从代码中的任何 subview 底部按下 TabBar 按钮(即更改 TabBar 的选定属性并显示启动第一个 View Controller 选项卡)。

如有任何帮助,我们将不胜感激。

戴夫

最佳答案

[myTabBarController setSelectedIndex:index]

编辑:回答评论中的第 2 部分问题:

您可以在 AppDelegate 中定义一个方法来切换到不同的选项卡。

而且您可以从任何地方获取 appdelegate 并发送消息..像这样的东西:

 MyAppDelegate *appDelegate = (MyAppDelegate*) [[UIApplication sharedApplication] delegate];
[appDelegate SwitchToTab:index]

关于iphone - 在 Xcode 中以编程方式按下 UITabBar 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1795407/

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