我正在处理一个视图,该视图的子视图是outlet是viewRect。我以编程方式在该视图上添加了UITapGestureRecognizer
来执行任务。
它适用于ios 10.3.1(iPhone 5),但不适用于iOS 9.2.1(iPhone 5)。
UITapGestureRecognizer *mTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(showView)];
[mTapGestureRecognizer setNumberOfTouchesRequired:1];
[self.viewRect addGestureRecognizer:mTapGestureRecognizer];
self.viewRect.userInteractionEnabled = YES;
回应方法
-(void)showView {
NSLog("tapped on view");
}
无法弄清楚为什么这不起作用。