Embed youtube video in IOS8 does not fill Webview width 100%

I have used the following code to show youtube video on iOS.

// Html string to display embedded youtube video in native webview

NSString *embedHTML = @"\
                    <style type=\"text/css\">\
                    body {\
                    background-color: transparent; background:none;\
                    </head><body style=\"margin:0\">\
                    <embed src=\"%@\"\
                    type=\"application/x-shockwave-flash\" width=\"%0.0f\" height=\"%0.0f\"></embed>\
                    NSString* html = [NSString stringWithFormat:embedHTML, http,viewRect.size.width, (viewRect.size.height*-1)];
                    videoView = [[UIWebView alloc] initWithFrame:CGRectMake(viewRect.origin.x , (viewRect.origin.y + viewRect.size.height), viewRect.size.width, (viewRect.size.height*-1))];
                    videoView.delegate = self;

                    //Stop Image Move
                    [videoView.scrollView setScrollEnabled:NO];
                    [self addSubview:videoView];
                    [videoView loadHTMLString:html baseURL:nil];
                    videoView.opaque = NO;
                    [self bringSubviewToFront:videoView];


I assigned the same width and height for both the web view and inline tag. Earlier in iOS7, this code works without issue. But in iOS8, the width of the YouTube video does not fill the webview. Please, I can really help if someone advises this issue.

Thanks in advance.


source to share

All Articles