7

我的應用程序的佈局如下 -的UIBarButtonItem沒有出現

的RootViewController的是各自具有一個UINavigationController作爲其RootViewController的3個標籤一個tabViewController。在其中一個選項卡中,我將單元格選擇推向另一個tabController,該tabController現在有兩個選項卡。我所試圖做的是建立在每個這兩個選項卡的viewControllers的rightBarButtonItem ......在這兩種的viewDidLoad方法我做:

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(selectionChanged:)]; 

然而,這是做絕對沒有!我從蘋果文檔中想到,您可以從導航控制器視圖層次結構中的任何位置設置navigationItem的rightBarButtonItem,但在這裏似乎不是這種情況。任何想法 - 如果有的話 - 我做錯了?

+0

我不知道爲什麼它不發生,但也許嘗試在看來會出現嗎? –

+0

不,沒有區別:/ – simonthumper

+0

明白了......需要做'self.tabBarController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(selectionChanged :)];' – simonthumper

回答

8

的解決方案是,以代替簡單地設置在self.navigationItem的rightBarButtonItem我們需要設置它的父tabBarController像這樣:

self.tabBarController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(selectionChanged:)];