简体   繁体   English

从UITableViewController发送消息到UITableViewCell

[英]Send message to UITableViewCell from UITableViewController

I have designed a table view in my storyboard that uses many interface elements. 我在情节提要中设计了一个使用许多界面元素的表格视图。 For example, I have a cell with a UIStepper in it, and a cell that segues to another modal view. 例如,我有一个带有UIStepper的单元格,以及一个可以选择另一个模式视图的单元格。 It contains static cells, as it is a simple data entry form and creating new UITableViewCell objects for each field would be a waste of time. 它包含静态单元格,因为它是一种简单的数据输入形式,并且为每个字段创建新的UITableViewCell对象将浪费时间。 However, I am using one custom cell from another point in the program. 但是,我正在从程序的另一点使用一个自定义单元格。 I have assigned the cell to be an instance of my custom UITableViewCell class, and have set the label and image view from the code (the custom cell is basic; two UILabels and a UIImageView ). 我已将单元格分配为自定义UITableViewCell类的实例,并已从代码中设置了标签和图像视图(自定义单元格是基本的;两个UILabels和一个UIImageView )。 I set a placeholder image in the viewWillAppear method. 我在viewWillAppear方法中设置了一个占位符图像。 The cell displays fine at first, however, when I change the label's text or the image in the code, the cell does not refresh until I tap it. 首先,该单元格显示正常,但是,当我在代码中更改标签的文本或图像时,直到我点击它,单元格才会刷新。 I read that using custom table view cells was the solution to this problem when it occurred with basic UITableViewCells , however, this does not seem to solve my problem. 我读到,使用自定义表格视图单元格是基本UITableViewCells出现时解决此问题的方法,但是,这似乎无法解决我的问题。 Is there a method I can declare in custom cell that reloads the cell when the data is changed? 我可以在自定义单元中声明一种方法,以在数据更改时重新加载该单元吗? If so, how? 如果是这样,怎么办?

Thanks! 谢谢!

更新了单元格后面的数据源中的信息(即图像或文本)后,应在UITableView上调用reloadRowsAtIndexPaths:withRowAnimation:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从 uitableviewcontroller 发送到 uitableviewcell - how to send data from uitableviewcontroller to uitableviewcell 将数据从UItableviewController传递到UItableViewcell - passing data from UItableviewController to UItableViewcell 如何从 UITableViewCell 类引用 UITableViewController? - How to reference UITableViewController from a UITableViewCell class? 在iOS中将数据从UItableviewController传递到UItableViewcell - Passing data from UItableviewController to UItableViewcell in ios 将选择器从UITableViewCell类添加到UITableViewController类 - Add a Selector from a UITableViewCell class to the UITableViewController class 快速从UITableViewCell删除存储在UITableViewController中的数据 - Swift remove data stored in UITableViewController from UITableViewCell 从自定义UITableViewCell调用UITableViewController中的方法 - Call method in UITableViewController from custom UITableViewCell 如何从UiTableViewController访问自定义UITableViewCell上的属性? - How to access properties on a custom UITableViewCell from a UiTableViewController? 单击按钮即可从UITableViewController访问UITableViewCell - Access UITableViewCell from UITableViewController on button click 将数据从UITableViewCell传递到UITableViewController的食谱 - Recipes to pass data from UITableViewCell to UITableViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM