UIPickerView with custom view and shortcuts not scrollable

I use the following code to add a label and 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 use the view is because I want to add two labels to this view and display them in the collector. The CustomPickerView and CustomPickerLabel classes contain the following code:

- (void)didMoveToSuperview { if ([[self superview] respondsToSelector:@selector(setShowSelection:)]) { [[self superview] performSelector:@selector(setShowSelection:) withObject:NO]; } }

The above code works fine for displaying and scrolling, but when I click on the shortcut to scroll, it does nothing. If I click only on the shortcut, as in the corners of the collector, the wheel rotates to the selection as it should.

Any suggestions would be appreciated.

Kind

+3
source share
1 answer

customView userInteractionEnabled NO. , YES, .

+5

Source: https://habr.com/ru/post/1769486/


All Articles