0
目前,我有1個視圖控制器,具有3個菜單:標籤欄項目將不會顯示
但是運行的時候,底部菜單/圖象都像被板缺或不完美展現像這樣:
應該有3個菜單。
代碼:
import UIKit
class TabBarReimbursementViewController: UITabBarController{
var loadTable: Bool = false
override func viewWillAppear(animated: Bool) {
self.viewControllers![selectedIndex].viewWillAppear(true)
}
override func viewDidLoad() {
super.viewDidLoad()
// self.tabBar.barTintColor = UIColor.redColor()
self.tabBar.tintColor = UIColor.blackColor()
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: #selector(TabBarReimbursementViewController.buttonClicked(_:)))
navigationItem.rightBarButtonItem = addButton
// UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor() ], forState: .Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blackColor() ], forState: .Selected)
let historySelected: UIImage! = UIImage(named: "history2.png")?.imageWithRenderingMode(.AlwaysOriginal)
let approvalSelected: UIImage! = UIImage(named: "approve2.png")?.imageWithRenderingMode(.AlwaysOriginal)
let listSelected: UIImage! = UIImage(named: "listlist2.png")?.imageWithRenderingMode(.AlwaysOriginal)
(tabBar.items![1]).selectedImage = historySelected
(tabBar.items![0]).selectedImage = approvalSelected
(tabBar.items![2]).selectedImage = listSelected
self.selectedViewController = self.viewControllers![1]
self.findHamburguerViewController()?.gestureEnabled = false
}
func buttonClicked(sender: UIBarButtonItem) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("MyRequestForm") as! myRequestForm
nextViewController.formType = "New"
self.navigationController!.pushViewController(nextViewController, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
你的意思是在標籤欄控制器或在菜單約束? – Borom1r
請檢查我的照片,我加了一些。我想我沒有使用約束 – Borom1r
標籤欄只能用於導航控制器。您不能直接將TabBar控制器連接到另一個視圖控制器。您必須在導航控制器中嵌入子視圖控制器,然後重試。 – KAR