如何使用多个选择器?

发布于 2024-12-23 10:58:47 字数 149 浏览 0 评论 0原文

我的应用程序收集各种类型的信息并将其发送到我们的服务器。有些问题是固定类型的,所以我需要使用选择器。当我在应用程序以选择数组启动时初始化选择器之前使用过选择器。我原以为我会通过各种子视图使用不同的选择器。只使用一个Picker,然后动态重置使用的数组会不会更好。如果是这样我该怎么做?

My app collects various types of information and sends it off to our server. Some of the questions are of fixed type so I need to use Pickers. When I've used pickers before they are initialised when the app starts with the array of selections. I had thought I would use different pickers through various subViews. Would it be better to use just one Picker and then reset the array used dynamically. If so how do I do this?

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

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

发布评论

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

评论(2

江湖彼岸 2024-12-30 10:58:47

请注意,数据源和委托协议的每个方法都包含一个 UIPickerView * 参数,例如:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

您需要使用它来区分两个实例,如下所示:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if([pickerView isEqual: pickerOne]{
  // return the appropriate number of components, for instance
     return 3;
}

if([pickerView isEqual: pickerTwo]{
  // return the appropriate number of components, for instance
     return 4;
}
}

Note that each method of both the datasource and the delegate protocols contain a UIPickerView * parameter, for instance:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

You need to use it to distinguish between your two instances, as follows:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if([pickerView isEqual: pickerOne]{
  // return the appropriate number of components, for instance
     return 3;
}

if([pickerView isEqual: pickerTwo]{
  // return the appropriate number of components, for instance
     return 4;
}
}
眸中客 2024-12-30 10:58:47

给两个不同的标签。并比较用于加载数组的标签。

Give the two different tags. And compare tag for loading your array.

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