[英]BarButton item with different behaviours
在當前的應用程序中,我有三個UIViewControllers,並且正在使用StoryBoard:
ViewController,MenuViewController,CategoriasListViewController。
為了從ViewController顯示MenuViewController,我正在使用按鈕動作。 為了從MenuViewController返回到ViewControler,我正在使用帶有以下操作方法的BarButton項:
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
為了從MenuViewController顯示CategoriasListViewController,我還使用了按鈕動作。 為了從CategoriasListViewController返回到MenuViewControler,我將使用具有以下操作方法(與上面相同)的BarButton項:
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
但是在這種情況下,不顯示MenuViewController,BarButton操作將被忽略。
我使用自定義的BarButton動作而不是默認的“后退”按鈕,因為在標題背景中,我有一個帶有徽標的圖像,該徽標會與默認的“后退”按鈕重疊。 歡迎任何幫助。 謝謝。
更新1:這是我的StoryBoard:
我在閱讀故事板時遇到困難,但是我很確定,如果您在方法中添加了一個斷點- (IBAction)backButton:(id)sender
您將達到該斷點。
我很確定當您按下按鈕時該方法正在被調用(除非您忘記鈎住它)。
該問題看起來像是將CategoriasListViewController
包裝在全新的Navigation控制器中。 因此,當-backButton:
get調用時,您是在與該新NavigationNavigator對話,而不是您真正要-backButton:
對話的原始-backButton:
。
刪除第二個不必要的UINavigationController,它應該可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.