有关使用 Google GData API - Youtube on iphone 的任何示例/教程? [英] Any examples/tutorials on using Google GData API - Youtube on iphone?
问题描述
我需要在 UITableView 中列出特定用户上传的视频 (YouTube).我已经下载了 GData 源和示例项目(不是特定于 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?
最好的问候,马格努斯
推荐答案
假设您已将 GData 客户端库包含到您的项目中,您需要调用以获取用户上传的内容,然后显示它们.这是我能想到的最简单的方法:
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:
在您的表视图控制器类中创建一个实例变量,用于保存从 YouTube API 返回的提要数据.
Create an instance variable in your table view controller class that will hold the feed data returned from the YouTube API.
#import "GDataYouTube.h"
#import "GDataServiceGoogleYouTube.h"
@interface RootViewController : UITableViewController {
GDataFeedYouTubeVideo *feed;
}
@property (nonatomic, retain) GDataFeedYouTubeVideo *feed;
在实现文件中,调用 API 以获取所有上传的视频.在回调选择器 request:finishedWithFeed:error
中,以任何适合的格式存储结果,并重新加载表格视图.在表格视图 cellForRowAtIndexPath
方法中,根据需要格式化单元格:
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:
// 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:)];
查看 RootViewController 的完整源代码.
Checkout the full source code for RootViewController.
这篇关于有关使用 Google GData API - Youtube on iphone 的任何示例/教程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!