Reputation: 1393
I have the following code:
self.shareButton=[[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 35, 35)];
[shareButton setBackgroundColor:[UIColor blueColor]];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button"] forState:UIControlStateNormal];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button_pressed"] forState:UIControlStateHighlighted];
[shareButton addTarget:self action:@selector(shareButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController setToolbarItems:[NSArray arrayWithObject:shareButton] animated:YES];
Why I cannot see toolbar buttons? What's the problem?
Upvotes: 0
Views: 788
Reputation: 25930
What meggar says is probably the right answer. Try doing it this way.
--UPDATE-- Since the problem still exists I have updated the example to move the set call to the view controller instead of the navigation controller.
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];
[self setToolbarItems:[NSArray arrayWithObject:barButtonItem] animated:YES];
[barButtonItem release];
Upvotes: 1