【发布时间】:2015-07-02 10:20:31
【问题描述】:
有谁知道如何为 TWTRTimelineViewController 设置单元格背景颜色?
我正在使用 Fabric 框架
cell.backgroundColor = UIColor.whiteColor() 等常用方法不起作用。
类参考可用here
【问题讨论】:
标签: ios swift uitableview twitter-fabric
有谁知道如何为 TWTRTimelineViewController 设置单元格背景颜色?
我正在使用 Fabric 框架
cell.backgroundColor = UIColor.whiteColor() 等常用方法不起作用。
类参考可用here
【问题讨论】:
标签: ios swift uitableview twitter-fabric
很抱歉回复晚了,但希望它对您或某人有所帮助。
您必须在 TWTRTimelineViewController 中重写 willDisplayCell 委托方法,如下所示:
对于swift 解决方案:
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if let cell = cell as? TWTRTweetTableViewCell {
cell.backgroundColor = .clearColor()
cell.tweetView.backgroundColor = .clearColor()
// Do what you want with your 'tweetView' object
}
}
对于Objective-c 解决方案:
-(void)tableView:(UITableView *)tableView willDisplayCell:(TWTRTweetTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor clearColor];
cell.tweetView.backgroundColor = [UIColor clearColor];
// Do what you want with your 'tweetView' object
}
记住TWTRTimelineViewController 是UITableViewController 的子类,这意味着您可以覆盖所有tableView 委托方法。
请参阅 https://dev.twitter.com/twitter-kit/ios-reference/twtrtweettableviewcell 了解如何将 cell 作为 TWTRTweetTableViewCell 类实例。
【讨论】:
使用下面的两个函数弄清楚了
TWTRTweetView.appearance().backgroundColor = UIColor.whiteColor()
TWTRTweetTableViewCell.appearance().backgroundColor = UIColor.whiteColor()
【讨论】:
// cell.backgroundColor = [UIColor blueColor];
cell.contentView.backgroundColor = [UIColor blueColor];
【讨论】:
在你的代码中写下以下几行:
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)
{
cell.backgroundColor = UIColor.whiteColor()
}
【讨论】:
尝试:
cell.tweetView.backgroundColor = UIColor.whiteColor()
您可以在以下位置找到更多详细信息:https://dev.twitter.com/twitter-kit/ios/show-tweets
【讨论】: