【发布时间】:2019-07-04 16:00:53
【问题描述】:
我有一个 UIButton 没有响应触摸事件。而且该按钮只有一些不处理事件的子视图。所以我用我自定义的 UIButton 替换它以找出发生了什么。以下是我的代码:
@interface CustomButton : UIButton
@end
@implementation CustomButton
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
}
-(BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
return [super beginTrackingWithTouch:touch withEvent:event];
}
@end
我发现touchesBegan:withEvent: 方法被调用,但beginTrackingWithTouch:withEvent: 从未被调用。似乎该事件已发送到我的按钮,但我不明白为什么从未跟踪过该事件。任何线索将不胜感激。
【问题讨论】:
-
我发现touchesBegan:withEvent:方法被调用了,但是touchesBegan:withEvent:从来没有被调用过。--是哪个?
-
@7stud 抱歉,我已经修正了我的错字。 :)
标签: ios uibutton event-handling responder-chain