1

I have a UIView subclass that contains a UIPickerView. The pickerview has a tap gesture recognizer attached. The idea is that users should be able to tap the pickerview once a row is selected. This worked previously, but after making some changes it is no longer working, and I've spent a day on it and am stuck.

The UIView is initialized like this:

self = [super initWithFrame:frame];
if (self)
{
    [Utility NSLogRect:frame caption:@"FRAME="];
    self.backgroundColor = [UIColor whiteColor];
    self.delegate = del;
    backgroundColor = color;
    videoList = [[NSMutableArray alloc] init];
    [self initializeView];
    [self displayPicker];
}
return self;


- (void) initializeView
{
    pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0f,0.0f,self.frame.size.width,self.frame.size.height)];
    pickerView.delegate = self;
    pickerView.dataSource = self;
    pickerView.showsSelectionIndicator = YES;
    pickerView.backgroundColor = backgroundColor;
    pickerView.alpha = 1.0f;
    UITapGestureRecognizer* gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerViewTapGestureRecognized:)];
    gestureRecognizer.cancelsTouchesInView = NO;
    gestureRecognizer.numberOfTapsRequired = 1;
    [pickerView addGestureRecognizer:gestureRecognizer];
    [self addSubview:pickerView];
    [self bringSubviewToFront:pickerView];
}

The picker displays the rows and scrolls correctly. However, the tap gesture does not call its action. Suggestions?

RegularExpression
  • 3,531
  • 2
  • 25
  • 36

1 Answers1

1

Is your UIView userInteractionEnabled?

You might wanna look at this , Dismissing UIPickerView on tapping background

Community
  • 1
  • 1
Debanjan
  • 99
  • 9
  • userInteractionEnabled didn't help the problem. After reading the link you posted I thought there might be something useful in there, tried a couple of things that came out of it but it didn't go anywhere. Thx. – RegularExpression May 31 '14 at 18:49
  • Unfortunately, userInteractionEnabled wasn't the problem. Looking at other alternatives. – RegularExpression May 31 '14 at 19:31
  • Then , try to remove the UIpickerView ; just add the Tapgesture on the UIView and fire a method to NSLog; See if then the Gesture is working – Debanjan Jun 02 '14 at 04:12