I have an array of folders. Each folder is listed as a table view row.
我有一个文件夹数组。每个文件夹都以表视图行形式列出。
When I display my table, I populate it with a set of textfields on the left hand side of the row (i want the user to be able to edit them) and a set of switches (on/off) on the right hand side of the row.
当我显示我的表时,我用行左边的一组textfields填充它(我希望用户能够编辑它们),以及行右边的一组switch (on/off)。
All is working well, you can touch the textfield and the keyboard appears. You can changed the values of the switch each time also.
一切运行良好,你可以触摸textfield和键盘出现。您也可以每次更改开关的值。
The problem I'm having is knowing which text field has been changed so that I can update my array ready to save the values.
我的问题是知道哪个文本字段被修改了,这样我就可以更新数组以保存值。
I'm using..
我用. .
[textField addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
and...
和…
-(void)textFieldDone:(UITextField *)textField
The problem is that the textField object does not contain any unique information about it in the textFieldDone selector. I've tried setting
问题是textField对象在textFieldDone选择器中不包含关于它的任何惟一信息。我试过设置
[textField setTag:rowNumber];
But it doesn't show as tag is not part of the textField object.
但是它并没有显示标记不是textField对象的一部分。
Anyone any ideas on the best way of doing this? Surely there must be lots of applications that have have textfields in table rows that you can switch between?
有什么好办法吗?肯定有很多应用程序在表行中有textfields,您可以在其中进行切换吗?
Or maybe I'm missing something here....
也许我在这里少了什么....
1 个解决方案
#1
0
Actually 'tag' is part of the UITextField as it is inherited from UIView.
实际上“标记”是UITextField的一部分,因为它是从UIView继承的。
Maybe I can suggest a different approach. Use your table view to display the data with a checkmark in the accessory view if the boolean value you are representing with a switch currently is set to YES. When the user taps that row, push a new view controller that contains a text field and a switch that the user can edit.
也许我可以提出另一种方法。使用您的表视图在附件视图中显示带有checkmark的数据,如果您所代表的布尔值当前设置为YES。当用户点击这一行时,按下一个新的视图控制器,该控制器包含一个文本字段和一个可供用户编辑的开关。
Is there an application you've seen that uses the UI method your attempting with the text field and switch in a table cell?
是否有一个应用程序使用用户界面方法来尝试文本字段并在表单元格中切换?
Keep in mind that you are probably reusing table cells, which is what you're supposed to do, however you may not be setting the tag on subsequent uses of that cell. Just guessing here.
记住,您可能正在重用表单元格,这是您应该做的,但是您可能没有在该单元格的后续使用中设置标记。只是猜测。
#1
0
Actually 'tag' is part of the UITextField as it is inherited from UIView.
实际上“标记”是UITextField的一部分,因为它是从UIView继承的。
Maybe I can suggest a different approach. Use your table view to display the data with a checkmark in the accessory view if the boolean value you are representing with a switch currently is set to YES. When the user taps that row, push a new view controller that contains a text field and a switch that the user can edit.
也许我可以提出另一种方法。使用您的表视图在附件视图中显示带有checkmark的数据,如果您所代表的布尔值当前设置为YES。当用户点击这一行时,按下一个新的视图控制器,该控制器包含一个文本字段和一个可供用户编辑的开关。
Is there an application you've seen that uses the UI method your attempting with the text field and switch in a table cell?
是否有一个应用程序使用用户界面方法来尝试文本字段并在表单元格中切换?
Keep in mind that you are probably reusing table cells, which is what you're supposed to do, however you may not be setting the tag on subsequent uses of that cell. Just guessing here.
记住,您可能正在重用表单元格,这是您应该做的,但是您可能没有在该单元格的后续使用中设置标记。只是猜测。