NavigationBar如果我的自定义ViewController被推送,则项目不会显示,只有以模态显示时才会显示。
出现导航栏,仅未显示项目。
如果按下VC,似乎找不到正确的NavigationController。
有什么想法吗?
The full Code on Github(FileExplorerViewController()
在被按下时被调用)
致电:
final class DirectoryContentViewController: UICollectionViewController {
let editBarButtonItem = UIBarButtonItem(title: viewModel.editActionTitle, style: .plain, target: self, action: #selector(handleEditButtonTap))
activeRightBarButtonItem = editBarButtonItem
扩展名:
extension UIViewController {
var activeRightBarButtonItem: UIBarButtonItem? {
get {
return activeNavigationItem?.rightBarButtonItem
}
set(newValue) {
navigationItem.rightBarButtonItem = newValue
activeNavigationItem?.rightBarButtonItem = newValue
}
}
var activeNavigationItem: UINavigationItem? {
guard let viewController = navigationController?.topViewController else { return nil }
if viewController.navigationItem === navigationItem {
return navigationItem
} else {
return parent?.activeNavigationItem
}
}
}