我有标准的 UIBarButtonItem
UIBarButtonItem *share = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)];
如何将她添加到UIToolBar?我试过了
self.toolbarItems = [NSArray arrayWithObject:share];
但它不起作用。需要你的帮助。
最佳答案
你能比“它不起作用”更具体吗?
如果您尝试向已有项目的工具栏添加项目,则需要修改项目数组:
NSMutableArray *newItems = [self.toolbarItems mutableCopy];
[newItems addObject:share];
self.toolbarItems = newItems;
关于objective-c - 如何在代码中的 UIToolBar 中添加 UIBarButtonItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5383906/