- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.userInteractionEnabled = YES;
}
return self;
}
- (void)addTarget:(id)target action:(SEL)action withArguments:(NSInteger)section
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
_target = target;
_action = action;
_section = section;
[self addGestureRecognizer:tap];
}
本文介绍了一个UIKit视图控制器如何通过使用手势识别器来添加触摸事件的目标和动作。通过初始化视图控制器并设置其可交互属性,文章详细展示了如何为特定的手势创建并附加一个UITapGestureRecognizer。
2183

被折叠的 条评论
为什么被折叠?



