UIPicker detect tap on currently selected row

后端 未结 8 1413
礼貌的吻别
礼貌的吻别 2020-12-01 10:11

I have a UIPickerView and The method didSelectRow is not called when tapping on a selected row. I need to handle

8条回答
  •  佛祖请我去吃肉
    2020-12-01 10:47

    Solution touchesBegan: / touchesEnded: worked fine for me when using iOS 4.2/4.3, but they stopped working with iOS. Finally I got this solution which may be helpful: using tap gesture recognition.

        IBOutlet UIPickerView *picker;
    
        [picker addGestureRecognizer:
            [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerTapped:)] autorelease]
        ];
    

    In this case when a user taps on picker view, the selector

        -(void)pickerTapped:(UIGestureRecognizer *)gestureRecognizer
    

    is invoked. Worked for me on both iOS 4.2+ / 5.0

提交回复
热议问题