Problema del indicador de selección de vista de UIPicker

I just want to know why the selection indicator looks like this in my iPad App. By "like this" I mean the first half has one color pattern and the other one has another. I'm creating my UIPickerView programatically like this:

pickerView = [[UIPickerView alloc] init];
pickerView.showsSelectionIndicator = YES;
pickerView.delegate = self;
pickerView.dataSource = self;

txtFolder.inputView = pickerView;

I need the pickerview to show the same color pattern. Any ideas?

UIPickerView selection indicator

preguntado el 30 de enero de 12 a las 19:01

Maybe there's some mistakes in the SDK... Have you tried to reinstall Xcode and the iOs SDK? -

2 Respuestas

I have been fighting with the same issue the whole day today.

I have similar code:

pickerView = [[UIPickerView alloc] init];
pickerView.showsSelectionIndicator = YES;
pickerView.delegate = self;
pickerView.dataSource = self;
[pickerView selectRow:0 inComponent:0 animated:NO];

txtFolder.inputView = pickerView;

So if you perform 'pickerView.showsSelectionIndicator = YES' after selecting a row it solves the problem.

La solución:

pickerView = [[UIPickerView alloc] init];
pickerView.delegate = self;
pickerView.dataSource = self;
[pickerView selectRow:0 inComponent:0 animated:NO];
pickerView.showsSelectionIndicator = YES;

txtFolder.inputView = pickerView;

Alex, try this, may be it will help you.

ACTUALIZACIÓN:

But the only true way is to show a picker within a popover. The cause of the issue is that a picker is not suitable for the main screen!

contestado el 11 de mayo de 12 a las 17:05

Same thing happened here today.

What I did to fix it was giving the picker the appropriate width.

Algo como esto:

int viewWidth = self.view.frame.size.width;
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, width, 150)];

respondido 23 nov., 12:01

A little late, this works a charm, to use the default keyboard height, specify a height of 0. - user352891

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.