我正在创建一个简单的应用程序,并希望顶部栏上有多个按钮。我添加了一个按钮,该按钮将添加新项目,但我也希望在那里有其他按钮供用户转到不同的屏幕。这就是现在的样子。
有没有办法在栏上添加其他按钮?如果是这样,怎么办?还是有一个用于此功能的标签栏很常见?这样的
最佳答案
是的,您可以在导航栏上有多个按钮。您可以将它们添加到栏的右侧或左侧。为此,您需要创建多个条形按钮并将它们添加为数组。像这样:
UIBarButtonItem *actionBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
UIBarButtonItem *addBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIBarButtonItem *bookmarksBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];
self.navigationItem.rightBarButtonItems = @[actionBtn, addBtn, bookmarksBtn]; //Considering that you want to have three buttons on the right side.
关于ios - 如何在iOS App的顶部导航上添加多个按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22812378/