0

I am a complete newbie in Swift, so excuse me if it may be a dumb question. I am trying to implement a way so that the content in the picker changes depending on which button is clicked. For example, let say there are two buttons "Months" and "Years". If I click Months button, I want a picker to appear with all it's content. But once I click Years button, I would like the same picker to appear with all the years instead (vice versa).

Is there a way to do this without creating a new UIPicker?

I tried creating a boolean flag to change some return values for pickerView functions, but it wouldn't work.

Thank You!

Lowan
  • 277
  • 3
  • 9

1 Answers1

1

Step 1:

Update all the array that your UIPickerView is using for display

Step2:

Simply call yourPickerView.reloadAllComponents()

Fangming
  • 24,551
  • 6
  • 100
  • 90