我在iPhone上app.I控制UIPickerview工作要me.Now我用下面的代碼我如何檢測觸摸在iphone的選擇指標的UIPickerView?
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pickerViewTapGestureRecognized:)];
[self.picker addGestureRecognizer:gestureRecognizer];
-(void)pickerViewTapGestureRecognized:(UITapGestureRecognizer *)gestureRecognizer
{
CGPoint touchpoint = [gestureRecognizer locationInView:gestureRecognizer.view.superview];
CGRect frame = self.picker.frame;
CGRect selectorFrame = CGRectInset(frame, 0.0, self.picker.bounds.size.height * 0.85/2.0);
if (CGRectContainsPoint(selectorFrame, touchpoint)) {
}
}
你想要什麼?爲什麼你想這樣做?你面臨的問題是什麼? – Bhavin
您是否需要在選取器視圖中返回選定的項目或返回座標? –
@ Vin,我需要觸摸發生在selectionIndicator或UIPickerview的其他部分。如何檢測觸摸? – IKKA