2016-06-16 139 views
-1

在我的應用程序我使用滑塊,所以我使用這個庫。 https://github.com/dekatotoro/SlideMenuControllerSwift 但使用這個我很困惑導航欄的使用。 在我的appdelegate我寫下這段代碼導航控制器後退按鈕不隱藏

window = UIWindow(frame: UIScreen.mainScreen().bounds) 
storyboard = UIStoryboard(name: "Main", bundle: nil) 
let controller123 : MainViewController = (self.storyboard!.instantiateViewControllerWithIdentifier("MainViewController") as? MainViewController)! 
let controllerright : drawerViewController = self.storyboard!.instantiateViewControllerWithIdentifier("drawerViewController") as! drawerViewController 
let controllerleft : RightViewController = self.storyboard!.instantiateViewControllerWithIdentifier("RightViewController") as! RightViewController 
let controller = SlideMenuController (mainViewController: controller123, leftMenuViewController: controllerleft, rightMenuViewController: controllerright) 

navigation = UINavigationController(rootViewController: controller) 
window?.rootViewController = navigation 
window?.makeKeyAndVisible() 

,並在我的mainviewcontroller我這段代碼

slideMenuController()?.addRightBarButtonWithImage(UIImage(named: "ic_menu_black_24dp")!) 

,因爲我想的抽屜右側

,並添加drwer當我選擇一個項目從抽屜我寫這個代碼

let controller123 : RightViewController = (self.storyboard!.instantiateViewControllerWithIdentifier("RightViewController") as? RightViewController)! 
let controllerright : drawerViewController = self.storyboard!.instantiateViewControllerWithIdentifier("drawerViewController") as! drawerViewController 
let controllerleft : RightViewController = self.storyboard!.instantiateViewControllerWithIdentifier("RightViewController") as! RightViewController 
let controller = SlideMenuController (mainViewController: controller123, leftMenuViewController: controllerleft, rightMenuViewController: controllerright) 

navigationController?.pushViewController(controller, animated: false) 

但現在發出我s我不能設置導航欄標題,甚至我不能隱藏回按鈕,所以我該如何解決?

enter image description here

+0

有你在演示代碼中使用檢查:self.navigationItem.setHidesBackButton(真,動畫:真); –

回答

1

嘗試這樣的事情。在drawerViewController

self.navigationItem.hidesBackButton = true 
self.navigationItem.title = "Your Title" 
//If you want to create a custom title View then try this 
self.navigationItem.titleView = yourview 

希望這將幫助你的viewDidLoad()方法添加此行。

0

試試這個代碼 「覆蓋FUNC viewWillAppear中(動畫:BOOL)」 當前視圖控制器:

navigationItem.hidesBackButton = true; 
navigationItem.title = "Hello"; 

希望這個代碼將幫助你。

0

在viewDidLoad中在從抽屜

導航每個視圖控制器試試這個
self.navigationItem.hidesBackButton = true 
self.navigationItem.title = "Title"