我在我的scrollview中有一個imageview,並且爲我的uiscrollview添加了一個水龍頭手勢。 關於uiscrollview中的水龍頭手勢
只有imageview區域可以響應輕擊手勢。
爲什麼當我設置滾動型的backgroudcolor財產,那麼整個滾動視圖可以響應雙擊手勢
這裏是我的代碼
UIImageView * imgview=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bizhi1.png"]];
imgview.frame=CGRectMake(0, 140, 320, 200);
UIScrollView * scrollview=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[scrollview addSubview:imgview];
//when i set the backgroudcolor,then the whole scrollview can respond tap gesture
//scrollview.layer.backgroundColor=[UIColor redColor].CGColor;
//add a TapGesture for scrollview
UITapGestureRecognizer * tapGesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SwitchTabBarHidden)];
[scrollview addGestureRecognizer:tapGesture];
[tapGesture release];
[imgview release];
[self.view addSubview:scrollview];
[scrollview release];
你想只在兩個圖像視圖的手勢? – 2013-05-09 04:38:49
只是想整個uiscrollview區域可以響應輕擊手勢。 – 2013-05-09 04:47:55
請獲取觸摸位置座標 - (void)singleTapGestureCaptured :(UITapGestureRecognizer *)手勢 – Deepesh 2013-05-09 04:48:03