例如點擊手勢
創建點擊手勢
UITapGestureRecognizer*tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickTapGestureView:)];
[tapView addGestureRecognizer:tap];
tapView.tag= 11111;
//點擊手勢的點擊方法
- (void)clickTapGestureView(UITapGestureRecognizer *)sender{
UIView *targetview = sender.view;
?????? if (targetview.tag == 1111) {
????? }else{
???? }
}
在iOS 中 手勢并沒有像控件那樣有tag值,但是有UIView屬性,我們可以通過給UIView添加tag從而達到標記手勢的效果。
UIView *targetview = sender.view;
是獲取手勢所在視圖
在通過Tag值進行判斷是哪個視圖