2012-06-04 80 views
2

在我的应用程序中,我从UITableview中获取Sever的视频链接。所有这些链接都存储在server.text中的文本文件中,但我想要在UITableview中获取这些链接的缩略图。这是我的形象。如何在UITableview中显示视频缩略图?

enter image description here

由于我的屏幕截图显示这是我从服务器上获取的链接,但在红色圆圈这些链接不显示缩略图。这些红色圆圈是我的webviews.here是我的代码。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CustomCellIdentifier = @"CustomCellIdentifier "; 
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier]; 
if (cell == nil) 
{ 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; 
    cell = [nib objectAtIndex:0]; 
} 
// Set up the cell. 
NSString *embedHTML = @"\ 
<html><head>\ 
<style type=\"text/css\">\ 
body {\ 
background-color: transparent;\ 
color: white;\ 
}\ 
</style>\ 
</head><body style=\"margin:0\">\ 
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ 
width=\"%0.0f\" height=\"%0.0f\"></embed>\ 
</body></html>"; 
NSString *html = [NSString stringWithFormat:embedHTML, [Listdata objectAtIndex:indexPath.row], cell.webSal.frame.size.width, cell.webSal.frame.size.height];  

cell.lblSal.text = [Listdata objectAtIndex:indexPath.row]; 
[cell.webSal loadHTMLString:html baseURL:nil]; 

return cell; 
} 

当我使用NSlog时,它显示了一些这样的事情。

enter image description here 任何人都可以指导我,我犯了什么错误。提前收到。

+0

看看这个问题:http://stackoverflow.com/questions/3405059/how-to-show-youtube-video-thumbnails – joern

+0

请在nslog之前写下html的值[cell.webSal loadHTMLString:html baseURL:nil] ; –

回答

1

您正在模拟器上测试。缩略图不会显示在模拟器上。在设备中运行时可以看到视频缩略图。

+0

@rakseshNS你的想法是正确的。当我检查它在设备上的工作很好。感谢您的答复。 – jamil

+1

我有同样的问题...“经验是最好的老师”:) – rakeshNS

+0

@ rakeshNS你是对的dear.thanx – jamil