I have a UIToolbar containing 2 UIBArButton items. The toolbar is inside a UITableViewCell, and it fades in when the user selects a cell. The problem is that when the cell get's highlighted, it calls highlight on the barButtonItems as well, and they stay highlighted until the user manually tap the button once, and then it goes back to standard highlighting.
Is there a way to unhighlight the UIBarButtonItems manually?
I tried the overriding the cell's setSelected:
and setHighlighted
methods, and have tried calling both setSelected:
and setHighlighted
on the subviews as well, as shown below, and it doesn't seem to work. highlighted is called on 1 UIToolbarBackground and 2 UIToolbarTextButtons. Any ideas?
@implementation CustomCell
// I also tried doing this in setHighlighted: & setHighlighted:animated
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
for (UIView *view in self.toolbar.subviews)
{
if ([view respondsToSelector:@selector(setHighLighted:)])
{
[view performSelector:@selector(setHighLighted:) withObject:[NSNumber numberWithBool:NO]];
}
}
}
@end