Reputation: 1292
I'm wanting to remove a image from a uibarbuttonitem and take it back to the default button style. The code I'm using to set the customview for the baritem is:
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 79, 29.0);
[backButton setImage:[UIImage imageNamed:@"imagehere.png"] forState:UIControlStateNormal];
[self.myItem initWithCustomView:backButton];
So what I'm asking is how can I remove the backButton CustomView and take it back to my default style? Thanks.
Upvotes: 0
Views: 988
Reputation: 94794
First off, [self.myItem initWithCustomView:backButton]
is wrong. You should always be doing something like self.myItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]
.
It does not seem that you can change the type of the UIBarButtonItem; when I tried assigning nil to the customView
property in a test app just now it screwed up the whole toolbar. Your best bet would be to just create a new UIBarButtonItem and reset the toolbars items
array.
Upvotes: 3