当在可可项目中按下按钮时,如何使 UIPickerView 更改值?

发布于 2024-12-26 03:30:25 字数 95 浏览 2 评论 0 原文

我正在运行 xcode 4.3,并且想知道如何让 UIPickerView 在按下同一视图上的按钮时更改其值。请发布一些与选择器更改相关的代码,因为我知道如何将其实现到按钮中。

I am running xcode 4.3, and would like to know how to make a UIPickerView change its values whenever a button on the same view is pressed. Please post some code pertaining on just the changing of the Picker, as I know how to implement it into the button.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

护你周全 2025-01-02 03:30:25

想必您的选择器是通过数组或类似的方式填充的?

如果是这样,则让按钮更改数组的内容,然后调用 [myPickerView reloadAllComponents];

Presumably your picker is being populated via an Array or similar?

If so then have the button change the contents of the array and then call [myPickerView reloadAllComponents];.

紫竹語嫣☆ 2025-01-02 03:30:25

我认为您只需要 UIPickerViewreloadAllComponents 方法。因此,在按钮操作方法中,请按照以下步骤操作:

  1. 更改 UIPickerViewDelegate 返回的数据。即更改您在 pickerView:titleForRow:forComponent: 中使用的任何对象以返回该行的标题。

  2. UIPickerView 上调用 reloadAllComponents

I think you just want UIPickerView's reloadAllComponents method. So in the button action method, follow these steps:

  1. Change the data that is returned by your UIPickerViewDelegate. i.e. change whatever object it is you're using within pickerView:titleForRow:forComponent: to return the title for that row.

  2. Call reloadAllComponents on your UIPickerView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文