2013-04-26 61 views
-1

我隱藏了導航欄,所以我可以在那裏有一個自定義的UIToolBar,但是當我將工具欄項目的action屬性設置爲彈出它的方法時,它不起作用,我認爲這可能是因爲我隱藏了導航欄。彈出視圖控制器關閉堆棧沒有導航欄顯示?

這裏是我的代碼:

[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Articles" style:UIBarButtonItemStyleBordered target:nil action:@selector(backButtonTapped)]]; 

...

- (void)backButtonTapped { 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

但沒有任何反應。

+0

你是什麼意思隱藏導航欄?檢查並查看您的導航控制器是否爲 – JeffN 2013-04-26 18:50:08

+0

[self.navigationController setNavigationBarHidden:YES animated:NO]; – 2013-04-26 18:52:07

+0

不,不是零。 – 2013-04-26 18:52:44

回答

0

我在UIBarButton上截取了水龍頭的整個視圖上都有一個UITapGestureRecognizer。我解決了它,歸功於this answer,它基本上停止了UITapGestureRecognizer的開始,除非它在UIToolBar之外。

3

你的選擇器的目標是零,當它應該是自己的,你需要把發送者參數放在你的動作方法中!

[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Articles" style:UIBarButtonItemStyleBordered target:self action:@selector(backButtonTapped:)]]; 

-(void) backButtonTapped: (id) sender { 
    //code as before here 
} 

編輯作爲@sulthan指出,發件人參數需要!你可以像以前一樣將它保留下來!

+0

這並沒有改變任何東西。 – 2013-04-27 02:23:08

+0

請給popViewcontrollerAnimated:方法添加一個斷點,並告訴我們它是否在點擊按鈕時被點擊。 – Mario 2013-04-27 06:31:45

+0

它不被調用。 – 2013-04-27 18:09:10

相關問題