我一直在用谷歌搜索这个问题。我有一个带有导航栏和底部工具栏的 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/