Workaround for missing UIBarButtonItem's TouchUp event
using a UIButton allows me to catch TouchUpInside and TouchUpOutside events to know when the user releases the button with his finger.
UIBarButtonItem doesn't have any events/notifications to be used in this manner.
Does anyone know a nice workaround to know when a UIBarButtonItem is physically released? Is there a way to use an UIButton in a UIToolBar with the sa开发者_StackOverflow中文版me "design" and behavior like a UIBarButtonItem?
Thanks!
IBOutlet UIBarButtonItem *barButton;
....
- (void)viewDidLoad
{
barButton.action = @selector(onBarButtonTap);
....
- (IBAction)onBarButtonTap
{
NSLog( @"BarButton Taped" );
}
If you are using a UIToolbar you can drag a UIButton into the bar. It will get embedded inside a UIBarButtonItem and you can link actions to the embedded UIButton
精彩评论