xcode选择器输出到数组 [英] xcode picker output into array

查看:59
本文介绍了xcode选择器输出到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有表格单元格视图,其中每个单元格必须代表用户选择器选择的输出.

I have table cell view with which each cell must represent the output of a picker selection by the user.

表格单元格视图有两个标签和一个按钮.按钮当然是调出选择器.(小右箭头)

The table cell view has two labels and a button. The button is to call up the picker of course.(little right arrow)

我需要返回单元格行号的第一个标签?

The first label i need to return the number of the cell row?

第二个标签需要返回用户的选择器选择.

The second label needs to return the picker selection of the user.

这是我在用户选择选择器时按钮的选择器实现方法文件中的内容:

This is what i have in my picker implementation method file for the button upon picker selection by the user:

    -(IBAction)buttonPressed
    {
NSInteger suitRow = [doublePicker selectedRowInComponent:
                      kSuitComponent];
NSInteger numberRow = [doublePicker selectedRowInComponent:
                        kNumberComponent];
NSString *suit = [suitTypes objectAtIndex:suitRow];
NSString *number = [numberTypes objectAtIndex:numberRow];

    This is where i need to put suit and number into array?
    i also want to return the row number?
}

所以我需要保存这两个值并将它们返回到我的另一个视图?

So i need to save those two values and return them to my other view?

推荐答案

由于您正在编辑现有行,因此大概已经创建了数组中的对象.所以你应该把这个对象传递给你的选择器视图控制器,并在上面的操作中编辑它.当您返回表视图时,您可能需要调用 reloadData

Presumably the object in your array is already created since you are editing an existing row. So you should pass this object to your picker view controller, and edit it in the action above. When you return to the table view you may need to call reloadData

在同一视图中编辑单元格可能值得一看,使用选择器作为单元格中字段的编辑视图.这会将所有内容保留在同一个控制器上并简化您的代码,因为您知道正在编辑哪个项目.

It may be worth looking at editing your cells in the same view, using the picker as the editing view of the field(s) in your cell. This would keep everything on the same controller and simplify your code as you'd know which item you were editing.

这篇关于xcode选择器输出到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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