Tiger
Tiger

Reputation: 310

iPhone webview in uitableview

UIWebView *webview=[[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 150, 120)];
NSString *media=@"http://www.youtube.com/watch?v=kG2BYhjQIKQ";
NSString *html = [NSString stringWithFormat:youTubeVideoHTML,media, 150, 120];

[webview loadHTMLString:html baseURL:nil];
[cell.contentView addSubview:webview];

It is not working , it displays only white view.

Upvotes: 0

Views: 185

Answers (2)

Abdullah Md. Zubair
Abdullah Md. Zubair

Reputation: 3324

To play youtube video on webView try the followings:

NSString *youTubeVideoHTML = @"<html><head>\
                          <body style=\"margin:0\">\
                          <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                          width=\"%0.0f\" height=\"%0.0f\"></embed>\
                          </body></html>";

    // Populate HTML with the URL and requested frame size
    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];

    // Load the html into the webview
    [self loadHTMLString:html baseURL:nil];

Upvotes: 1

Senthilkumar
Senthilkumar

Reputation: 2481

[webview loadHTMLString:html baseURL:nil]; is use to load into the UITextview if you want to use UIwebview means

[webView loadRequest:[NSURLRequest requestWithURL:url]];

Upvotes: 1

Related Questions