Swift tabbar 将选择器添加到 tabItem

标签 swift xcode

我正在为我的标签栏 Controller 使用自定义弹出菜单。我需要标签栏项目来打开菜单。我需要添加选项卡栏项,而不将它们引导到任何 View Controller 。我尝试在我的 tabcontroller 类中将它们设置为 nil,但它不会接受 nil 项。如果我能够将它们添加到选项卡栏,它将在委托(delegate)中触发

func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {


}

最佳答案

我解决这个问题的方法是将选定的索引设置回我想要的位置 tabBarController.selectedIndex = 0

关于Swift tabbar 将选择器添加到 tabItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41555217/

相关文章:

iphone - 在 UITableView 中显示来自 Core Data 的下载队列

ios - iOS应用提交错误:处理json请求时发生错误

ios - UIViewController 部分标题未显示

ios - 在 Objective-C 中存储到 Keychain 的值无法在 Swift 中检索?

swift - RealmObject Equatable 冗余消息

xcode - 为什么我的 Xcode 项目上的测试是红色的?

ios - 如何在针对较旧的 iOS 版本时添加需要 iOS 12 的自定义 Intent?

swift - 通话中的额外参数

ios - UITableViewCells 未出现在第二个选项卡中

objective-c - 接收者类型 'WebFrame' 例如消息是前向声明