0
我必须在导航栏的右侧有两个按钮。所以我创建了一个工具栏并在其内容视图中添加了两个栏按钮项目。如下所示。navigationItem.rightBarButtonItem需要两个按钮。图像没有显示
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像另一个barbutton项目下
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithCustomView:toolbar];
[toolbar release];
我在右栏上显示两个栏按钮项目,但我无法显示图片分享按钮项目上。它只是一个白色的补丁。任何机构都可以告诉我我做错了什么或如何显示图像。
问候,
赛优素福
嗨贝格曼, 非常感谢。是的,我使用的是不透明的图像。我使用了等效的灰度图像,它确实显示在导航栏中。 Regards, Syed Yusuf – 2009-10-30 17:32:04
如果您觉得它回答了问题,请将答案标记为已接受。 – 2009-10-30 18:19:03