1
我目前正在開發一個聊天應用程序,在此我必須在導航欄中添加多於一個的左側欄按鈕。我正在使用xib文件開發它。在iOS的頂部導航欄中添加多個然後一個按鈕
我已經添加了左右欄按鈕,現在我想在導航欄的左側添加2個按鈕。
我目前正在開發一個聊天應用程序,在此我必須在導航欄中添加多於一個的左側欄按鈕。我正在使用xib文件開發它。在iOS的頂部導航欄中添加多個然後一個按鈕
我已經添加了左右欄按鈕,現在我想在導航欄的左側添加2個按鈕。
UINavigationItem Class Reference具有leftBarButtonItems和rightBarButtonItems屬性,以便您可以使用下面的示例代碼在您的導航控制添加多個UIBarButtonItem
:
UIBarButtonItem *FirstButton = [[UIBarButtonItem alloc]
initWithTitle:@"First"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(AcionFirst:)];
UIBarButtonItem *secondButton = [[UIBarButtonItem alloc]
initWithTitle:@"Second"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(AcionSecond:)];
self.navigationItem.leftBarButtonItems= [NSArray arrayWithObjects:FirstButton,secondButton,nil];
-(void)AcionFirst:(id)sender
{
//do something for first bar button
}
-(void)AcionSecond:(id)sender
{
//do something for second bar button
}
You'l得到很多,如果你只是谷歌*** UINavigationBar的多個按鈕** * – 2014-09-04 10:53:46
[如何將2個按鈕添加到沒有IB的右側的UINavigationbar中?]可能的重複(http://stackoverflow.com/questions/1803609/how-to-add-2-buttons-into-the-uinavigationbar在右邊 - 沒有ib) – 2014-09-04 10:54:44
@rahul你必須給出一些答覆和評論。 – 2014-09-05 12:16:45