Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
469 views
in Technique[技术] by (71.8m points)

uitableview - Any examples/tutorials on using Google GData API - Youtube on iphone?

I need to list a specific users uploaded videos (YouTube) in a UITableView. I've downloaded the GData source and example projects (not iphone specific) but I can't seem to get it to work. Does anybody know of any good (or any at all ;)) tutorials out there?

Best regards, Magnus

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Assuming you have included the GData client libraries to your project, you need to make a call to fetch the user's uploads, and then display them. Here's the simplest way I can think of:

Create an instance variable in your table view controller class that will hold the feed data returned from the YouTube API.

RootViewController.h

#import "GDataYouTube.h"
#import "GDataServiceGoogleYouTube.h"

@interface RootViewController : UITableViewController {
    GDataFeedYouTubeVideo *feed;
}

@property (nonatomic, retain) GDataFeedYouTubeVideo *feed;

Inside the implementation file, make a call to the API to fetch all uploaded videos. Inside the callback selector request:finishedWithFeed:error, store the results in whatever format suits, and reload the table view. In the table views cellForRowAtIndexPath method, format the cell as desired:

RootViewController.m

// get the youtube service
GDataServiceGoogleYouTube *service = [self youTubeService];

// feed id for user uploads
NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
// construct the feed url
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:@"annoyingorange"
                                            userFeedID:uploadsID];

// make API call
[service fetchFeedWithURL:feedURL
         delegate:self
         didFinishSelector:@selector(request:finishedWithFeed:error:)];

Checkout the full source code for RootViewController.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...