【发布时间】:2010-03-07 23:00:04
【问题描述】:
我必须在导航栏的右侧有两个按钮。所以我创建了一个工具栏,并在其内容视图中添加了两个栏按钮项。如下所示。
UIBarButtonItem *shareButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"share-icon-32x32.png"]
style:UIBarButtonItemStyleBordered
target:self action:@selector(showShare)];
shareButton.width = 30.0f;
[buttons addObject:shareButton];
[shareButton release];
其中buttons是一个保存按钮对象的数组。
同样,我还有另一个条形按钮项目,如下所示
UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(addDescription)];
addButton.style = UIBarButtonItemStyleBordered;
[buttons addObject:addButton];
[addButton release];
现在将数组添加到工具栏,如下所示
[toolbar setItems:buttons animated:YES];
[buttons release];
并将其添加到 rightBarButton 如下所示
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithCustomView:toolbar];
[toolbar release];
我在右侧栏上获得了两个栏按钮项目,但我无法将图像显示在共享按钮项目上。它只是一个白色的补丁。任何人都可以告诉我我做错了什么或如何显示图像。
问候,
赛优素福
【问题讨论】:
标签: iphone