I've got a UIToolbar with a couple of buttons:
I'm changing the items in the toolbar. I remove the last button that says "Sell this Asset..." and add a new UIBarButtonItem titled "Finish Sale" like so:
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items removeLastObject];
[items addObject:self.barButtonCompleteSale];
[self.toolbar setItems:items animated:YES];
The problem: The UIToolbar isn't updating correctly. It appears that the spacer between "Edit" and "Sell this Asset..." is the item getting removed and the "Finish Sale" item is being added, but it's sitting ON TOP of the "Sell this Asset" button.
This happens on the simulator (iOS 4.3 and iOS 5.0) as well as on a device (iOS 5.0). Why is this happening?
I have no idea what happened, but I decided to move that UIBarButton item out of the toolbar (just to keep it around in the xib for later comparison) and then I added a fresh, new UIBarButton item to the toolbar, changed the title, hooked up the IBAction and everything is working fine now.
There must have been something weird behind the scenes in the xib, but I have NO idea what caused it. Recreating the button seems to have fixed it though.