-[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] 是什么? [英] What is -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] for?

查看:31
本文介绍了-[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我所有的 UITableView 编程中,我总是在 -[UITableViewDataSource tableView:cellForRowAtIndexPath:] 中配置我的 UITableViewCells.现在我遇到了 -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] 方法.这似乎也是进行单元配置的合适场所.

In all of my UITableView programming, I've always configured my UITableViewCells in -[UITableViewDataSource tableView:cellForRowAtIndexPath:]. Now I've come across the -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] method. That also seems like an appropriate place to do cell configuration.

我的问题是:这两种方法之间合适的分工"是什么?我应该怎么做?

My question is: what's the appropriate "division of labor" between these two methods? What should I do in one vs. the other?

推荐答案

您可以使用它来配置字体和文本颜色等内容.在较新版本的 iPhone 中,具有某些表格配置,如果您在 tableView:cellForRowAtIndexPath: 方法中配置标签文本颜色之类的内容,您的更改将在单元格实际存在之前的某个时刻丢失显示.您可以在此处执行更改标签颜色、调整背景突出显示等操作.

You use that to configure things like font and text color. In the newer version of the iPhone, with certain table configurations, if you configure things like the label text color in the tableView:cellForRowAtIndexPath: method, your changes will be lost at some point before the cell is actually displayed. Here you can do things like change the label's color, adjust background highlighting, such things as these.

这篇关于-[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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