gpt4 book ai didi

ios - moreNavigationController 在 UITabBarController 中始终为 nil

转载 作者:可可西里 更新时间:2023-11-01 01:17:16 24 4
gpt4 key购买 nike

我正尝试在我的 UITabBarController 中自定义“更多”按钮的标题,因为我正在用另一种语言开发该应用程序。我将 UITabBarController 子类化,以便能够访问 tabBarController 属性。不幸的是,无论我将它放在viewDidLoad 还是viewDidAppear(_) 中,它总是nil。关于如何编辑它有什么想法吗?

import UIKit

class ControllerVC: UITabBarController {

let uiManager = UIManager()

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewDidAppear(_ animated: Bool) {
if let tabBarItem = tabBarController?.moreNavigationController.tabBarItem {
let deselectedImage = tabBarItem.image
let selectedImage = tabBarItem.selectedImage
tabBarController!.moreNavigationController.tabBarItem = UITabBarItem(title: "بیشتر", image: deselectedImage, selectedImage: selectedImage)
} else {
uiManager.showActivityIndicator(self)
}
}

}

最佳答案

问题不在于 moreNavigationController。问题出在 tabBarController 上。您的类是 UITabBarController。标签栏 Controller 的 tabBarController 属性始终为 nil

只是做:

let tabBarItem = moreNavigationController.tabBarItem
let deselectedImage = tabBarItem.image
let selectedImage = tabBarItem.selectedImage
moreNavigationController.tabBarItem = UITabBarItem(title: "بیشتر", image: deselectedImage, selectedImage: selectedImage)

关于ios - moreNavigationController 在 UITabBarController 中始终为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45749505/

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