关于多组件依赖uipickerview的实现 [英] Regarding implementation of multi component dependent uipickerview

查看:146
本文介绍了关于多组件依赖uipickerview的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解多组件uipickerviews的概念。我真的很想拥有这个主题。我想用一个相互依赖的组件制作一个4组件的pickerview。

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.

第一个组件是从我的数据库中的数组填充的,这显示正常。我有所有其他信息在数组中可用,但我只是挂在我的pickerview的依赖方面。我认为使组件2的数据依赖于comp 1的最佳方法是在didSelectRow部分中以某种方式链接它们。但我不知道语法。

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...

另一个问题是确定numberOfRowsInComponent位,因为它们不在同一个方法中...

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.

推荐答案

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

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.

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

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.

这篇关于关于多组件依赖uipickerview的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆