我目前在自定义单元格中嵌入了youtube视频的tableview.
我这样做是因为从我的研究中看来,这似乎是允许视频加载而不离开我的应用程序的唯一方法.
问题是这样的:
缩略图需要一段时间才能加载.
当我向下滚动视频列表时,它不断加载thunbnails.
如果我向上滚动...它会再次尝试加载视频缩略图.
有没有人对更好的方法有什么建议,或者让表格单元格保留数据而不是替换它的方法?
我的代码看起来像这样:
CustomVideoCell *cell = (CustomVideoCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomVideoCell"];
if (cell == nil) {
UIViewController *temporaryController = [[UIViewController alloc] initWithNibName:@"CustomVideoCell" bundle:nil];
cell = (CustomVideoCell *)temporaryController.view;
[temporaryController release];
GDataEntryBase *entry = [[self.feed entries] objectAtIndex:indexPath.row];
NSString *title = [[entry title] stringValue];
NSString *videoID = [[(GDataEntryYouTubeVideo *)entry mediaGroup] videoID];
NSString *htmlString =
[
[NSString alloc]
initWithFormat:@"<html><head><meta name = \"viewport\" content = \"initial-scale = 2.0, user-scalable = no, width = 110\"/></head><body style=\"background:#000;margin-top:0px;margin-left:0px\"><div><object width=\"110\" height=\"90\"><param name=\"movie\" value=\"http://www.youtube.com/v/%@&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/%@&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\" …
Run Code Online (Sandbox Code Playgroud)