Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPickerView reloadData

I'm changing components (in particular, the number and color of components), in a UIPickerView that I call pickerOne, so after making the changes, I call:

[pickerOne reloadData];

and it appears to be working perfectly however, I'm getting a compile warning:

warning: 'UIPickerView' may not respond to '-reloadData'

Although this appears to work, is there something else that I should use to reload data?

Thanks

like image 994
Matt Winters Avatar asked Jul 08 '10 18:07

Matt Winters


People also ask

What is UIPickerView in swift?

A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values.

What is a UIPickerView?

UIPickerView is a subclass of UIView . It is useful for iOS apps that use a spinning wheel with many choices for the user. @MainActor class UIPickerView: UIView. One example of this type of app is a slot machine, where a user spins the wheels to play the game.

What is component in pickerview?

UIPickerView can have multiple wheels (named components), and are numbered starting at 0. For example, a picker view with 3 components looks like the following where. the first wheel ("6") is component 0. the second wheel ("00") is the component 1. the third wheel ("AM") is the component 2.

What is pickerview iOS?

A picker view can be defined as the view that shows a spinning wheel or slot machine to display one or more set of values so that the user can spin the wheel to select one. It is an instance of UIPickerView class which inherits UIView.


2 Answers

I think you should be using:

reloadComponent:

or

reloadAllComponents:

like image 76
Avalanchis Avatar answered Oct 21 '22 22:10

Avalanchis


You should be calling reloadComponent: or reloadAllComponents:.

There may be a private reloadData used under the covers, but it's not part of the public API, and therefore, shouldn't be relied upon.

like image 21
MarkPowell Avatar answered Oct 21 '22 21:10

MarkPowell