简体   繁体   English

缺少UIBarButtonItem的TouchUp事件的解决方法

[英]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. 使用UIButton可以捕获TouchUpInside和TouchUpOutside事件,以了解用户何时用手指释放按钮。

UIBarButtonItem doesn't have any events/notifications to be used in this manner. UIBarButtonItem没有以这种方式使用的任何事件/通知。

Does anyone know a nice workaround to know when a UIBarButtonItem is physically released? 有没有人知道一个很好的解决方法,知道UIBarButtonItem何时被物理释放? Is there a way to use an UIButton in a UIToolBar with the same "design" and behavior like a UIBarButtonItem? 有没有办法在UIToolBar中使用UIButton具有相同的“设计”和行为,如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. 如果您使用的是UIToolbar,可以将UIButton拖到栏中。 It will get embedded inside a UIBarButtonItem and you can link actions to the embedded UIButton 它将嵌入到UIBarButtonItem中,您可以将操作链接到嵌入的UIButton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM