我已经在服务器上建立了10个youtube视频链接。每个youtube视频都应该在webview中显示缩略图。 viewcontroll以及如何在运行时为(redbox)区域中从上到下的每个youtube链接创建webview的信息。任何建议或帮助都会被告知。
最佳答案
为此,您可以将scrollview
与webview
结合使用。
首先在 View 中添加一个滚动 View (在红色矩形的位置)
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,150,150)]; //You need to set the frame according to your need.
scrollView.contentSize = CGSizeMake(150,600);
scrollView.userInteractionEnabled = YES;
[self.view addSubview:scrollView];
[self.view bringSubviewToFront:scrollView];
现在将十个Web View 添加到该滚动 View
int yPos = 0;
for(int loop = 0; loop<10;loop++)
{
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,yPos,50,50)]
NSString *htmlString = @"<html><head>
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>
<body style=\"background:#F00;margin-top:0px;margin-left:0px\">
<div><object width=\"212\" height=\"172\">
<param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param>
<param name=\"wmode\" value=\"transparent\"></param>
<embed src=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed>
</object></div></body></html>";
//if your video url's are stored in an array then
NSString *str = (NSString *)[urlArray objectAtIndex:loop];
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@str]];
[scrollView addSubview:webView];
[webView release];
webView = nil;
yPos += 70;
}
[scrollView release];
这将在页脚 View 中添加10个小型的管状嵌入式播放器。您可以滚动页脚以查看视频的缩略图。
注意:您需要根据 View 更改框架和内容大小。
关于iphone - 如何在ViewController的底部使用多个Webview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11566177/