如何根据模态视图中的选择更新 UITableViewCell 的详细文本?
我正在尝试根据单击单元格时显示的模态视图中的 UIPickerView
中的选择来更新 UITableViewCell
的详细信息文本。
当用户单击父视图中的单元格时,会弹出模态视图,然后向他呈现一个 UIPickerView,当他选择完所需的值后,用户单击“保存”按钮。用户单击“保存”按钮后,模态视图消失,他单击的单元格上的详细信息标签的文本将更新为他使用模态视图的 UIPickerView
选择的值。
不幸的是我想不出一个好的、干净的方法来做到这一点...... 我是 iOS 编程新手,我想知道是否有任何“传统”方法可以做到这一点,我也很感激任何其他方法来实现这一点。
非常感谢!
I am trying to update a UITableViewCell
's detail text according to a selection from a UIPickerView
in a Modal View presented when the cell is clicked.
The Modal View pops up when the user clicks a cell in the parent view, then he is being presented with a UIPickerView
and when he is done selecting he's desired value, the user clicks the "save" button. After the user clicks the "save" button the Modal View goes away, and the text of the detail label on the cell in which he clicked gets updated with the value he selected with the Modale View's UIPickerView
.
Unfortunately I can't think of a good, clean, way to do that...
I am new to iOS programming and I would like to know if there is any "traditional" way of doing that, I would also appreciate any other way of achieving this.
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您知道提示模态视图的
indexPath
,并且您应该知道,那么简单地获取对单元格的引用并直接更改detailTextLabel
可能很诱人,如下所示:不是最好的,因为它不一定反映模型的状态并且不提供动画。最好的办法是确保更新支持 tableview 的模型数据,然后执行如下操作:
有许多
UITableViewRowAnimation...
可供选择,但动画可以帮助用户看到他们确实做出了改变。If you know the
indexPath
that prompted the modal view, and you should, it may be tempting to simply grab reference to the cell and change thedetailTextLabel
directly like so:But this is not the best because it doesn't necessarily reflect the state of the model and provides no animation. The best thing to do is make sure to update the model data that backs your tableview and then do something like this:
There are many
UITableViewRowAnimation...
s to choose from including none, but animation helps the user see that they actually made a change.