Saturday, 15 January 2011

ios - Loading array of user tweets for embedded user tweet timeline -


The code below displays a table view successfully, which is displayed in the 'tweets' array. Can anyone tell me how can I modify it to display all the tweets for a particular user handle or thragh? I think I have to use the loadUserWithID method from Twitter kit, but I'm not sure how to implement it. Many thanks

Import UIKit Import TwitterKit Class TwitterViewController: UITableViewController, TWTRTweetViewDelegate {// Go tweetTableReuseIdentifier = "TweetCell" hold Tweets on all filled tweets: [TWTRTweet] = [] {{didSet tableView. ReloadData ()}} go tweetIDs = ["184,701,590"] // viewDidLoad () {Twitter.sharedInstance function override our favorite bike tweets) LogInGuestWithCompletion {guestSession, if there is an error, (guestSession! = Void) {Twitter.sharedInstance () .APIClient.loadTweetsWithIDs (self.tweetIDs) {Tweets, error if TS = as tweets? [TWTRTweet] {self.tweets = ts} else {println ("Failed to load Tweets: \ (error.localizedDescription)")}}}} // Setup table view tableView.estimatedRowHeight = 150 tableView.rowHeight = UITableViewAutomaticDimension // The automatic line height is clearly set using the calculation table; Int {return self.tweets.count} override function tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) - & gt; UITableViewCell {twitter = Tweets [indexPath.row] let's cell = tableviews. DEqueueReusableCellWithIdentifier (TWITTweetTableViewCell cell.tweetView.delegate = self cell.weetView.delegate = self cell.configureWithTweet Returns cell} as the overlad func tableView (tableview: UITableView, heightforevateindexpace indexpath: NSIndexpath) -> CGFloat {tweet = Tweets [indexPath.row] Return TWTRTweetTableViewCell.heightForTweet go (tweets, width: CGRectGetWidth (self.view.bounds)}}

TwitterKit supports a user time showing directly

  class UserTimelineViewController: TWTRTimelineViewController, TWTRTweetViewDelegate {SUVE Dont init () {Let dataSource = TWTRUserTimelineDataSource (screen name: "TomCruise", APIClient: TWTRAPIClient ()) self.init (data source: datasource) self.title = "@ \ (dataSource.screenName)"} func tweetView (tweetView) : TWTRTweetView, didSelectTweet Tweet: TWTRTweet) {Print ("Selected Tweets with ID: \ (tweet.tweetID)")}}  

You can see more details here:


No comments:

Post a Comment