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?