1

是否可以在彈出窗口中的UIViewController中顯示工具欄項目?我在我的視圖控制器的viewDidLoad方法這樣做:popover中的UIToolbar

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil]; 
    [self setToolbarItems:[NSArray arrayWithObject:addButton]]; 
    [addButton release]; 

然後我在UINavigationController包裝這個視圖控制器(其中有一個toolbar財產,並根據文檔,我應該使用setToolbarItems方法UIViewController將項目添加到工具欄),然後將其呈現在彈出窗口中。

我沒有看到工具欄。使用彈出窗口時工具欄是否不受支持?

感謝

回答

6

想通了,顯然是工具欄默認是隱藏的,所以你必須這樣做:

[self.navigationController setToolbarHidden:NO animated:NO]; 

使其出現。

+0

謝謝!我現在要使用它... – 2011-03-30 05:36:22

+0

好吧,它工作:)但我似乎無法添加按鈕。很可能會很快弄清楚。再次感謝。 – 2011-03-30 05:46:57

+0

一個善良的人只爲我回答了一個問題:這些按鈕被添加到popover中顯示的視圖中。 [鏈接] http://stackoverflow.com/questions/10853038/how-do-i-add-buttons-to-a-toolbar-within-an-ipad-popover [/鏈接] – mpemburn 2012-06-01 19:58:52