swiftuipickerview

UIPIckerview strange display behaviour


I have an app written a few years ago using UIPickerView and had been working until now.

It doesn't display properly for iOS 16. So I thought I'd use Xcode to submit another build with the latest libraries etc but it still doesn't work!

I've attached the screenshots, you can see from the first one it should be "17 10 00" but it's showing "... ... ..." (but you can see "18 11 01").

enter image description here

So I select "18 11 01" but it shows "... 11 ..." (but now you can see "17 10 ..." above it).

enter image description here

There's no fixed pattern as to which numbers are displayed. All seem random.

I've made the picker quite big (like in this case) and it still doesn't display properly, so it's not a matter of the font size being too big for the display field.

Has anyone seen this or know how to fix it?

The numbers are selected correctly and displays correctly in a text label.


Solution

  • I found the code where the column width was set and lo and behold, once I changed the value of the width the numbers appear correctly again! And then I put in a "pickerView(_ pickerView: UIPickerView, viewForRow row: Int" to set the font size to a fixed value rather than leaving it to default, and the problem is solved!