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)];
精彩评论