Gre*_*reg 7 iphone uitableview ios
为什么设置一个UITableViewCell颜色willDisplayCell但是没有cellForRowAtIndexPath?
笔记:
[cell setBackgroundColor:[UIColor yellowColor]];- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathUITableViewCell你需要做的状态的doco willDisplayCell: (摘自UITableViewCell下面的类引用).我怀疑因为表格单元格有一个内容视图和各种其他似乎被"管理"的组件UIKit,所以它在设置之后用背景颜色做自己的事情cellForRowAtIndexPath.您还可以使用表格视图单元格的"backgroundView"属性来控制其背景.
文件摘录:
注意:如果你想改变一个单元格的背景色(通过设置通过单元格的背景颜色backgroundColor通过声明的属性UIView),你必须这样做在tableView:willDisplayCell:forRowAtIndexPath:委托的方法,而不是在tableView:cellForRowAtIndexPath:数据源.组样式表视图中单元格背景颜色的更改在iOS 3.0中具有与以前版本的操作系统不同的效果.它现在影响圆角矩形内的区域而不是它外面的区域.
| 归档时间: |
|
| 查看次数: |
2402 次 |
| 最近记录: |