Reputation: 2437
I already had 10 youtube video links on server.Every youtube video should be thumbnail in webview.in a given image the (redbox) show the space is less for showing all youtube thumbnails in webview,so how we can scroll the (redbox) area of viewcontroll and how to create webview at runtime for each youtube link top to bottom in (redbox) area.Any suggestion or help will be appriated.thanx in advance
Upvotes: 0
Views: 283
Reputation: 107211
For achieving this you can use scrollview
with webview
.
First add a scroll view in the view (at the red rectangle's position)
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];
Now add ten webviews to that scroll 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];
This will add 10 small you tube embedded players in your footer view. You can scroll the footer to see the thumbnails of the video.
Note: You need to change the frames and content size according to your views.
Upvotes: 2