开发者

How to change the number of components in a UIPickerView?

I have a UITableView for different datas. When the user select one row, then I will popup a UIPickerView to let the user select some values. And I have implemented the numberOfComponentsInPickerView DataSource method to return the number of components for different row in the UITableView. actually they are all 1.

But now, I will download more data from the internet and add more rows in the UITableView. I called [picke开发者_如何转开发rView reloadAllComponents] after finishing the downloading. I expected the numberOfComponentsInPickerView will be called so I can have more components in the picker view for the new rows in UITableView. But it's not working.

How can I do that? thanks.


In XCode 4.2 running on an IOS 5 device, I was able to get [pickerView reloadAllComponents] to change the number of components in a UIPickerView.

It works exactly as you originally expected it to. Calling reloadAllComponents caused the numberOfComponentsInPickerView method to get called.


I found a solution for my problem. Instead of trying to make the UIPickerView reload and change the number of components dynamically, I use two UIPickerView, one has 1 component, and the other has two. And I will switch between these two when the user select different rows of data in the tableview.

Hope this can help if other people has similar need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜