如何在UITableViewCell
中获取YouTube视频,如何处理播放视频Done
的{{1}} - 按钮?
我已将视频嵌入到视图中,但就像在图像上一样。我希望在此图片中显示UIWebView
- 按钮:
我想在返回视图时打开另一个屏幕,而不是之前的视图。
Done
我需要一些帮助。我做了一个搜索,但我没有得到任何东西。
答案 0 :(得分:0)
由于这一点没有得到答复,我想我可能会提出一个建议。我认为最终的结果与您所寻找的结果相同,但实现目标的路径略有不同。
因此,根据我的理解,您希望UITableView控制器显示您点击它们时播放的YouTube视频列表。以下是我在其中一个应用程序中处理此方案的方法。
didSelectRowAtIndexPath Implementation
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
/** self.items is just a mutable array of video objects that is the underlying
datasource for the table. The Video object is just a simple value object
I created myself */
Video *video = [self.items objectAtIndex:[indexPath row]];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:video.video]];
[self presentMoviePlayerViewControllerAnimated:mp];
[mp release];
}
以下是我的Video类的界面
@interface Video : NSManagedObject {
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * link;
@property (nonatomic, retain) NSString * comments;
@property (nonatomic, retain) NSString * thumbnail;
@property (nonatomic, retain) NSString * pubDate;
@property (nonatomic, retain) NSString * video;
@property (nonatomic, retain) NSString * guid;
@property (nonatomic, retain) NSString * desc;
@end
这就是它,在UITableViewController中显示YouTube视频的简单方法。我不会进入XML解析,有大量关于如何做到这一点的文档。我只是做了一个快速的谷歌,这个博客实际上进入我正在谈论的具体细节:
http://useyourloaf.com/blog/2010/10/16/parsing-an-rss-feed-using-nsxmlparser.html
希望这能让你前进。我知道这并不能解决将标记放在WebView中的问题,但我认为你会发现这种方式更加直观,因为没有很多回复......希望它会让你开始运行。
答案 1 :(得分:0)
您要做的事情涉及搞乱UIWebView使用的媒体播放器。这可以通过监视uiviewanimation通知然后浏览一组子视图来完成,但它将涉及使用私有方法,因此不建议特别是因为私有媒体播放器的行为随每个操作系统的变化。我建议使用jerrylroberts回答并直接链接到YouTube视频。