TWTRTimelineViewController

TWTRTimelineViewController

有谁知道如何为TWTRTimelineViewController设置单元格背景颜色?

我正在使用Fabric框架

cell.backgroundColor = UIColor.whiteColor()这样的常规方法不起作用。

类参考可用here

最佳答案

抱歉,您的回复很晚,但希望对您或其他人有帮助。
您必须在willDisplayCell中重写TWTRTimelineViewController委托方法,如下所示:

对于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
}

记住TWTRTimelineViewControllerUITableViewController的子类,这意味着您可以覆盖所有tableView委托方法。

请参阅https://dev.twitter.com/twitter-kit/ios-reference/twtrtweettableviewcell以了解如何将cell作为TWTRTweetTableViewCell类实例使用。

08-26 05:38