gpt4 book ai didi

ios - 如何让 tabBarController 在第二个ViewController加载时自动加载

转载 作者:行者123 更新时间:2023-11-30 11:20:10 25 4
gpt4 key购买 nike

所以我有一个带有4个项目(ViewController)的UITabBarController,我希望它在每次加载MainTabBarController时加载第二个ViewController。还有其他方法可以实现这一点吗?

self.tabBarController?.selectedViewController = self.tabBarItem.homeMapViewController

对我不起作用

最佳答案

您可以子类化 UITabBarController 并将其设置在 viewDidLoad

self.selectedIndex = 1

//

class CustomTabBar:UITabBarController {

override func viewDidLoad() {
super.viewDidLoad()
/// ......
self.selectedIndex = 1
}
}

并将CustomTabBar分配给IB中Tabbar的类

关于ios - 如何让 tabBarController 在第二个ViewController加载时自动加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51343935/

25 4 0
文章推荐: 在服务器的所有 drupal 网站中注入(inject) Javascript
文章推荐: java - 为什么 Object 类的 clone() 方法提供对象的深拷贝?
文章推荐: javascript - 在 JavaScript 和 HTML 中,如何获取当前按钮所在的
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com