4

我可以将系统项分配给 aUIBarButtonItem而无需重新创建它吗?仅在现有按钮上调用initWithBarButtonSystemItem似乎对我不起作用。

是我尝试使其工作的代码。我正在尝试使用 PhoneGap 改进对 iOS 的本机控件支持。该插件允许毫无问题地更改标题/图像,但我必须弄清楚如何将系统提供的图标分配给现有按钮。

4

1 回答 1

17

I took a look at your code, didn't find your use of initWithBarButtonSystemItem. However, this is what I'm doing in a similar case with native iOS programming:

UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];

self.navigationItem.rightBarButtonItem = myButton;
[myButton release];

This works correctly for me. I'm not familiar with PhoneGap and it may or may not change things however.

于 2012-06-28T14:41:21.393 回答