关于多组件依赖的uipickerview的实现

发布于 2024-09-06 18:26:22 字数 600 浏览 11 评论 0原文

我无法理解多组件 uipickerviews 的概念。我真的很想拥有这个主题。我想制作一个 4 组件选择器视图,其中的组件相互依赖。

第一个组件是从我的数据库中的数组填充的,并且显示得很好。我在数组中拥有所有可用的其他信息,但我只是对我的 pickerview 的依赖方面感到困惑。我认为使组件 2 的数据依赖于组件 1 的最佳方法是以某种方式在 didSelectRow 部分中链接它们。但我不知道语法。

我已经为此工作了几个小时,感觉自己已经很接近了,但我只是需要一些帮助来解决一些问题。连接组件以使它们相互依赖的语法是什么?像这样的东西吗? (我知道这很糟糕,但我认为这是我需要得到的方向):

if(picker = pickerComponent1)
     //set number of rows for comp2 and also the content etc...

另一个问题是确定 numberOfRowsInComponent 位,因为它们不采用相同的方法......

如果有人知道(或想要给出: )关于这个主题的教程,它会很有帮助!或者,如果您对该主题很了解并且想分享一些您所知道的内容,那也是完美的。我真的很希望看到这个看似简单的任务完成。

I am having trouble grasping the concept of multi component uipickerviews. I really would like to just OWN this subject. I would like to make a 4 component pickerview with components that are dependent on one another.

The first component is being populated from an array from my db, and that is showing up fine. I have all of the other info available in arrays, but I am just getting hung up on the dependent aspect of my pickerview. I figure the best way to make component 2's data depend on comp 1 is to link them somehow within the didSelectRow section. But I don't know the syntax.

I have been working at this for hours now and feel like I am really close, but I just need some help with a few issues. What is the syntax for connecting components so they depend on each other? Something like this? (Which is awful I know, but I am thinking that is the direction I need to get) :

if(picker = pickerComponent1)
     //set number of rows for comp2 and also the content etc...

Another issue is determining the numberOfRowsInComponent bit because they aren't in the same method...

If anyone knows about (or wants to give :) a tutorial on this subject, it would be so helpful! Or if you are knowledgeable on the topic and would like to share some of what you know, that would be perfect too. I would really like to see this seemingly simple task completed.

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

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

发布评论

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

评论(1

橘寄 2024-09-13 18:26:22

这很简单。在 pickerView:didSelectRow:inComponent: 方法中,只需为选择更改的组件之后的所有组件调用 [myPicker reloadComponent:] 即可。然后,选择器将自动向其数据源(可能是您的视图控制器)询问行数和行的值。

然后,在 pickerView:numberOfRowsInComponent:pickerView:titleForRow:forComponent: 中,根据父级的值返回适当的值(相应数组的计数和内容)组件的选定行。

It's quite simple. In the pickerView:didSelectRow:inComponent: method, just call [myPicker reloadComponent:] for all components coming after the one where the selection changed. The picker will then automatically ask its datasource (your view controller, presumably) for the number of rows and the rows' values.

Then, in pickerView:numberOfRowsInComponent: and pickerView:titleForRow:forComponent:, return the appropriate values (the count and contents of the corresponding array) depending on the values of the parent components' selected rows.

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