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

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

问题描述

在我的所有 UITableView 编程中,我总是在 - UITableViewCells > [UITableViewDataSource tableView:cellForRowAtIndexPath:] 。现在我遇到了 - [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:] for?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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