What can cause UIPickerView display bug on iPhone?

252 views Asked by At

I am subclassing UITextField to be able to set UIPickerView as an inputView. When my text field becomes first responder, UIPickerView shows up in place of keyboard.

The problem is, in some cases (especially when I set custom component widths), presented picker shows strange display artefacts. See attached picture.

What causes this strange display bug?
enter image description here

1

There are 1 answers

0
Lukasz On BEST ANSWER

Turned out to be pretty simple. It looks like iPhone hates when you set UIPickerView frame by yourself. One must leave it to the framework by initializing it with CGRectZero frame.

UIPickerView *pv;
//pv = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 300, 162)];
pv = [[UIPickerView alloc] initWithFrame:CGRectZero];