簡體   English   中英

UINavigationController工具欄按鈕

[英]UINavigationController Toolbar Buttons

我有一個UINavigationController我已經設置為我的窗口的rootViewController。 在NIB文件中,我已將其設置為具有“工具欄”的“底欄”。 在Interface Builder中,我添加了一個UIBarButtonItem。 這一切都很好,我可以處理按鈕單擊罰款。 當我點擊其中一個按鈕時,我將一個新視圖推送到ViewController上,這也很好用。 一個問題,我的按鈕在加載視圖時消失。 現在在后續視圖中我可以將底欄設置為工具欄,我在Interface Builder中看到它,但我無法添加任何按鈕。

我知道我要么錯過了一些明顯的東西,要么想錯了但是如何將UIBarButtonItems添加到推送到導航控制器的后續視圖中? 我說的是底部的欄,而不是頂部的導航欄。

有任何想法嗎?

UIViewController上的toolbarItems屬性是您感興趣的。您可以以編程方式創建UIBarButtonItems並將它們添加到viewDidLoad中的新toolBarItems數組中。

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem* editButton = [[[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(editAction)] autorelease];
    [self setToolbarItems:[NSArray arrayWithObject:editButton]];
}

這對我來說效果更好:

[[self navigationItem] setLeftBarButtonItem:homeButton];

您可以在右側執行相同的操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM