In order to display a Youtube video, construct the htmlString as show in the snippet below. You can adjust the height and width as required.Normally 320×480 works best for iPhone. The Youtube video url is passed as input to the htmlString. Finally the UIWebView displays the video by rendering html loaded through the loadHTMLString method once its added to the view.


– (void) displayGoogleVideo 
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize screenSize = rect.size;
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,screenSize.width,screenSize.height)];
    webView.autoresizesSubviews = YES;
    webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
    NSString *videoUrl = @”″;
    NSString *htmlString = [NSString stringWithFormat:@”<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=”320″ height=”480″><param name=”movie” value=”%@”></param><param name=”wmode” value=”transparent”></param><embed src=”%@” type=”application/x-shockwave-flash” wmode=”transparent” width=”320″ height=”480″></embed></object></div></body></html>”,videoUrl,videoUrl]    ;
    [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@””]];
    [window addSubview:webView];
    [webView release]; // CLANG BUG FIXED