I'm using the following code to add a label and a view to a UIPickerView.
- (UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component
reusingView:(UIView *)view {
CustomPickerView *customView = [[CustomPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, 180, 32)];
CustomPickerLabel *pickerLabelLeft = [[CustomPickerLabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 80, 32)];
[pickerLabelLeft setTextAlignment:UITextAlignmentRight];
pickerLabelLeft.backgroundColor = [UIColor clearColor];
[pickerLabelLeft setText:@"1234"];
[customView addSubview:pickerLabelLeft];
return customView;
}
The reason I'm using a view is because I want to add two labels to this view and display them in the picker. The CustomPickerView and CustomPickerLabel classes contain the following code, each:
- (void)didMoveToSuperview
{
if ([[self superview] respondsToSelector:@selector(setShowSelection:)])
{
[[self superview] performSelector:@selector(setShowSelection:) withObject:NO];
}
}
the above code works fine for display and scrolling, but when I click on the label to scroll, it does nothing. If I click just outside the label, as in the corners of the picker, the wheel turns to the selection as it should.
Any suggestions would be appreciated.
Rod