我有一个关于在 UIToolbar 上隐藏、删除或添加 UIBarbuttonItem 的问题。
我有一个 UIToolbar 和两个项目。我希望在工具栏上隐藏一个项目,当我输入第三个 UITableview 时,它会出现。
我已将此代码放入我的 viewDidload
instruct = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"b_info.png"] style:UIBarButtonItemStylePlain target:self action:@selector(instruct_clicked:)];
instruct.title =@"instructions";
spacebetween = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
items = [NSMutableArray arrayWithObjects:vorige, spacebetween, aanwijzingen, spacebetween, nil];
[toolbar setItems:items]
现在我想要的是,在我的程序中的某个时刻,我调用了一个函数,该函数要么将另一个项目添加到工具栏。
这里的例子
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
... ..
...
...
//and then something like this
[items addObject: anotherButton];
[工具栏设置项目:项目]
}
我想我可以在我的 mutableArray 中添加另一个项目,但不幸的是我无济于事。有没有人有线索或想法。