0

I'm trying to load user timeline and customize cells, like replacing some text with emojis then display it. The sample code to load user timeline provided by twitter is like this:

override func viewDidLoad() {
    super.viewDidLoad()
    let client = TWTRAPIClient()
    self.dataSource = TWTRUserTimelineDataSource(screenName: "someuser", 
                      apiClient: client)
}

But I could not find any detail about customizing TWTRTweetTableViewCell while using data source method.

4

1 回答 1

1

From the docs for TWTRTimelineViewController (link):

This class is a UITableViewController subclass that displays TWTRTweetTableViewCell cells.

That means you can override any UITableView delegate methods you wish.

For example, to set the background color of the cell to Orange:

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    if let twCell = cell as? TWTRTweetTableViewCell {
        twCell.tweetView.backgroundColor = .orange
    }
}

It appears there are also "themes" you can configure. Just read through the docs... https://dev.twitter.com/twitterkit/ios/appledocs/Classes/TWTRTweetView.html

于 2017-10-13T13:00:52.260 回答