开发者

add a "+" button in a navigationBar

I try to add a "add button" in the navigationBar, but the button who is created is a rectangle button with no text inside, not a "+" button, why?

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonSystemItemAdd target:self action:@selector(ajouterItem)];

self.navigationItem.rightBarButtonIte开发者_运维问答m = addButton;

[addButton release];


You're mixing up the initializer with the one for title/style. You want this form:

- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action

Call it like this:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(ajouterItem)];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜