以下mwthod是UINavigationController的委託方法。我想成爲會員,決定是否將左側項目添加到每個頁面。下面的代碼不起作用,我做錯了什麼?iOS - UINavigationController並添加一個左欄按鈕?
我不想通過ViewController本身執行此操作。我希望NavigationCopntroller負責此任務。
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(menuItemSelected:)];
[self.navigationItem setLeftBarButtonItem:menuItem];
// I also tried
// [viewController.navigationItem setLeftBarButtonItem:menuItem];
}
這樣解決了嗎? – 2012-08-08 19:59:00
是的,忘記標記爲答案。 – aryaxt 2012-08-09 03:40:43