gpt4 book ai didi

ios - 如何在 iOS 中为 UITabBarController 的更多 View Controller 设置 selectedindex

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

如何将 setSelectedIndex 设置为 UITabBarController 以显示存在于 More View 中的 View Controller 。

我尝试使用以下代码设置索引

    // To redirect user to home screen
TBDDashboardTabBarController *tabBar = segue.destinationViewController;
[tabBar setSelectedIndex:5];

但由于 iOS 最多只能显示 5 个标签,并且索引超出可见标签,因此索引 View Controller 未显示。

如果我将 setSelectedIndex 设置为 0 到 3,如 [tabBar setSelectedIndex:2];,效果很好。仅当我尝试将索引设置为大于 3 时问题才会出现。

我在 Google、stackoverflow 和其他论坛中尝试过,但没有成功。最接近的提示是 How to get UIMoreListControllers child view controllers

请帮我解开这个谜题。

最佳答案

您可以使用selectedViewController 显示您需要的 Controller 。快速代码:

destination.selectedViewController = destination.viewControllers![4]

关于ios - 如何在 iOS 中为 UITabBarController 的更多 View Controller 设置 selectedindex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32086137/

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