为什么 UITableViewCell 背景颜色不起作用(在界面生成器中设置)? [英] Why doesn't UITableViewCell background color work (set in interface builder)?

查看:17
本文介绍了为什么 UITableViewCell 背景颜色不起作用(在界面生成器中设置)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 UITableViewCell 背景颜色不起作用(在界面生成器中设置)?

Why doesn't UITableViewCell background color work (set in interface builder)?

我从一些搜索中注意到,在您的 UITableViewController 的自定义子类中设置的以下代码确实有效(见下文):

I note from some searching that the follow code set in your custom subclass of UITableViewController does work (see below):

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor redColor];
}

但我仍然想了解为什么界面生成器有 TableViewCell 的背景颜色设置,这实际上似乎不起作用?

But I would still like to just understand why interface builder has a background color setting for the TableViewCell, which effectively doesn't seem to work?

推荐答案

(试试这个)

Apple 的 IB 设计通用,可应用于多种组件,并且还针对高技术受众(开发人员).因此,它没有被设计为(作为应用程序)为每个组件/情况类型正确地完全自定义界面.所以在这种情况下,看似设置背景颜色的能力有点误导.

Apple's IB's design is generic to be applied to multiple kinds of components, and is also targeted at a highly technical audience (developers). Hence it has not been designed (as an application) to fully customise the interface properly for each component/situation type. So in this case it is the case the ability to seemingly set the background-color is somewhat misleading.

这篇关于为什么 UITableViewCell 背景颜色不起作用(在界面生成器中设置)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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