UITableViewCell 中的 UITextField 与 UIPickerView?
处理目录订购 iPad 应用程序的产品数量的最合适方法是什么?我目前正在努力尝试使用 UITableViewCell
中的 UITextField
设置此值。该应用程序根据产品的第一个字母按字母顺序显示产品。我使用 UINavigationBar
内的 SegmentedControl
进行设置,它根据点击的字母刷新单元格,仅显示该字母的产品,该字母在整个系统中不相同木板。
我昨天发布了一个 问题来设置我更倾向于使用 UITextFields ,而使用 UITextFieldDelegate
是答案。我仍然面临该选项的问题是,当我为 textField
输入数字时,由于某种原因,它会在其他单元格上显示它。当我上下滚动列表时,它会不断用该值填充随机单元格,并且在某些情况下,从实际应该包含该值的单元格中删除该值。
今天,我变得越来越绝望,并试图找到处理这些数量的选择。可能使用 UIPickerView 或其他类型。有人做过类似订购目录之类的工作吗?非常感谢任何有关如何解决此问题的共享信息。
What is the most suitable way to handle the product quantity for a catalog ordering iPad app. I am currently struggling trying to set up this values with UITextField
s in UITableViewCell
s. The app displays the products in an alphabetical way depending on the first letter for the product. I have it set up using a SegmentedControl
inside a UINavigationBar
which refreshes the cells depending on the alphabet letter tapped, displaying only the products for that letter which is not the same across the board.
I posted a question yesterday to set up UITextFields for which using the UITextFieldDelegate
was the answer I was more inclined to use. The problem that I still face with that option is that when I enter a number for the textField
, it for some reason displays it on other cells. When I scroll up and down the list it keeps populating random cells with that value, and in some cases, removing the value from the cell that should actually have it.
Today, I am growing desperate and am trying to find options to handle those quantities. Probably using a UIPickerView
, or some other type. Has anyone worked on something like an ordering catalog? Any shared info on how to approach this is more than greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的第一个倾向是您应该实现
-tableView:willDisplayCell:forRowAtIndexPath:
并使用索引路径来确定与该项目关联的当前数量。不确定您的数据是如何设置的,但我会将这些信息保存在关联的数组中。这是一个例子
My first inclination is that you should implement
-tableView:willDisplayCell:forRowAtIndexPath:
and use the index path to determine the current quantity associated with that item. Not sure how your data is setup, but I would keep this information in an associated array.Here's an example
我使用 UITextFieldDelegate 的 shouldReturn 方法使用可变字典来存储值,让它完美地工作。从那里,我只需让它显示从字典到产品代码的匹配值。
I got it to work perfectly using a mutable dictionary to store the values using the shouldReturn method for the UITextFieldDelegate. From there, I would simply make it display the matching value from the dictionary to the productCode.