2013-03-13 118 views
3

我想在我的項目中使用storyboard來實現JASidePanels。你可以在這裏看到我的故事板。JASidepanels not displayed navigationbutton

enter image description here

的問題是,我沒有看到在導航欄按鈕顯示leftpanel。在我的RootViewController中,我使用了代碼。

-(void) awakeFromNib 
{ 
    [self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"]]; 
    [self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"]]; 
    [self setRightPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"]]; 
     self.shouldResizeLeftPanel = YES; 
    self.shouldResizeRightPanel = YES; 
    [self setRightFixedWidth:300.0f]; 
    [self setLeftFixedWidth:300.0f]; 

} 

我遵循了他們在github page上說的步驟。 另外,當我嘗試嵌入RootviewControllernavigationController。它顯示的是navigationBar,但不是barbutton item

對此有何幫助?

回答

9

嵌入你的心的UIViewController在故事板到UINavigationController的,例如:

  1. 選擇的UIViewController在故事板
  2. 選擇Xcode的菜單編輯器 - 嵌入 - 導航控制器
  3. 選擇新的UINavigationController的身份檢查(Alt鍵-Command-3)
  4. 賦予StoryBoard ID唯一的名稱eg myCenterController
  5. 使用該名稱創建中央面板

    [自setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@ 「myCenterController」]];

所以你實際上並沒有將viewController設置爲centerPanel,而是一個包含viewController的導航控制器。

+0

完美,作品像一個魅力! – CGR 2016-11-24 17:24:28

0

好吧,我使用的是swift 2.2,我也看不到導航按鈕。

我正在使用故事板;所以我創建:

  • MainViewController - >這將是主容器
  • LeftMenuViewController - >這是在左邊的菜單
  • ProductsViewController - >這將是內MainViewController

所以在MainViewController,我建立了我的VC如下:

self.leftPanel = self.storyboard?.instantiateViewControllerWithIdentifier("LeftMenuViewController") //for left menu and 

self.centerPanel = UINavigationController.init(rootViewController: (self.storyboard?.instantiateViewControllerWithIdentifier("ProductsViewController"))!) 

添加UINavigationController.init將解決這個問題,你會看到在中央面板上的導航按鈕。