Search code examples
iostwittertwitterkit

How to show retweets and like counts in iOS TwitterKit?


In twitterKit, there is a tweetView for displaying the Tweet from tweet model object, but there is no field for showing retweets and likes counts in the tweetView.

cell.tweetView.showActionButtons = true;

This allow us to show action buttons for favorite and share. But I want to show the retweet/likes counts in each tweets. How can I achieve?


Solution

  • Just subclass a regular UITableViewCell and use a TWTRTweetView inside of it. Which is basically what TWTRTweetTableViewCell does, it has a tweetView property which is essentially an IBOutlet of type TWTRTweetView and use that in the tableview cell instead.

    Place the custom label for like and retweets counts in proper position on top of the TWTRTweetView.

    - (void)configureCell:(TWTRTweet *)tweet{
      self.customTweetView.showActionButtons = true;
      [self.customTweetView configureWithTweet:tweet];
      self.likesCount.text = [NSString stringWithFormat:@"%lld", tweet.likeCount];
      self.retweetsCount.text = [NSString stringWithFormat:@"%lld", tweet.retweetCount];
    }
    

    For more info: check this SO post