iphone - UITableViewController 不显示工具栏项目?

标签 iphone ios uitableview uitoolbar

我一直在用谷歌搜索这个问题。我有一个带有导航栏和底部工具栏的 TableView Controller 。我能够显示工具栏

self.navigationController.toolbaHidden = NO;

然后我像这样向工具栏添加了一些项目

UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
button.titleLabel.text = @"Button";
UIBarButtonItem *buttonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
[self setToolbarItems:[NSArray arrayWithObject:buttonItem] animated:NO];
[button release];

但是它从来没有用过。我认为这是正确的做法,但不知何故它在工具栏上什么也没显示。有谁知道原因是什么?或者,如果您知道添加工具栏项目的正确方法,请告诉我?非常感谢大家。

干杯,

最佳答案

 UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
     UIBarButtonItem *buttonItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:nil];
  self.toolbarItems=[NSArray arrayWithObjects:buttonItem,buttonItem2,nil];
    self.navigationController.toolbarHidden = NO;

似乎因为你在 barbutton 中添加了圆形按钮,它没有显示,尝试添加带有系统提供的 barbuttons 的工具栏,它肯定会工作

关于iphone - UITableViewController 不显示工具栏项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10415515/

相关文章:

ios - 在 Swift 中使用 Facebook 自定义登录获取用户信息

ios - 在 UILabel 中显示日文注音假名

ios - UITableViewCell 神秘地改变高度

iphone - iOS 7 中带有 Cap Insets 问题的可调整大小的图像

iphone - 在 UIPageViewController 中禁用/启用滚动

iphone - iPhone 应用程序中的导航后退按钮项目事件

ios - 当我按下完成 iOS 时,textview 键盘没有退出

iphone - 未调用 UIApplicationDelegate 方法

ios - 在 uitableview, IOS 中突出显示第一个单元格时遇到问题

iphone - 如何清除 UITableViewCell 上的删除确认状态