Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIWebView在全屏播放视频时打破限制(Xcode 6)_Objective C_Uiwebview_Youtube_Ios8_Xcode6 - Fatal编程技术网

Objective c UIWebView在全屏播放视频时打破限制(Xcode 6)

Objective c UIWebView在全屏播放视频时打破限制(Xcode 6),objective-c,uiwebview,youtube,ios8,xcode6,Objective C,Uiwebview,Youtube,Ios8,Xcode6,我正在更新YouTube频道的iOS应用程序。在以前的版本(iOS7使用Xcode 5)中,我曾将youtube iFrame嵌入到UIWebView中,一切正常 然而,在使用Xcode 6的iOS 8中,每当我播放Youtube视频并使其全屏显示时,我的UIWebView约束将被打破,UIWebView将在我的控制器中重新定位(通常在屏幕上移10个点) 我试图改变约束条件,但似乎不管我设置了什么约束条件,当玩家全屏播放时,约束条件最终会被打破 以下是用于嵌入YouTube iframe的htm

我正在更新YouTube频道的iOS应用程序。在以前的版本(iOS7使用Xcode 5)中,我曾将youtube iFrame嵌入到UIWebView中,一切正常

然而,在使用Xcode 6的iOS 8中,每当我播放Youtube视频并使其全屏显示时,我的UIWebView约束将被打破,UIWebView将在我的控制器中重新定位(通常在屏幕上移10个点)

我试图改变约束条件,但似乎不管我设置了什么约束条件,当玩家全屏播放时,约束条件最终会被打破

以下是用于嵌入YouTube iframe的html代码:

- (void)embedYouTube:(NSString *)urlString
{
NSString *embedHTML =[NSString stringWithFormat:@"\
                      <html><head>\
                      <style type=\"text/css\">\
                      body {\
                      background-color: transparent;\
                      color: blue;\
                      }\
                      </style>\
                      </head><body style=\"margin:0\">\
                      <iframe height=\"140\" width=\"325\"      src=\"http://www.youtube.com/embed/%@\"></iframe>\
                      </body></html>",urlString];
[self.webView loadHTMLString:embedHTML baseURL:nil];
-(void)embeddeYouTube:(NSString*)urlString
{
NSString*embedHTML=[NSString stringWithFormat:@”\
\
\
身体{\
背景色:透明\
颜色:蓝色\
}\
\
\
\
“,urlString];
[self.webView loadHTMLString:EmbedHtmlBaseURL:nil];
}

由于日志很大,我已将其粘贴到pastebin中:


谢谢:)

我也有同样的问题。但是,我没有遇到重新定位问题(使用Xcode 6.1),只有一堆破坏约束的日志

我测试的仍然无法工作: -移除约束,并将所有webview及其子视图的TranslatesAutoResizingMaskinToConstraints设置为YES -将UIWebview与WKWebview交换,WKWebview是更新更快的UIWebview

我还测试了播放Dailymotion视频,它也有同样的问题,所以我怀疑这更像是UIWebview的MediaPlayer视图的问题

像这样试试看

- (void)embedYouTube:(NSString*)url frame:(CGRect)frame {  
     NSString* embedHTML = @"\ 
        <html><head>\ 
     <style type=\"text/css\">\ 
     body {\ 
     background-color: transparent;\ 
     color: white;\ 
     }\ 
     </style>\ 
     </head><body style=\"margin:0\">\ 
        <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ 
     width=\"%0.0f\" height=\"%0.0f\"></embed>\ 
        </body></html>";  
     NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height];  
     if(videoView == nil) {  
       videoView = [[UIWebView alloc] initWithFrame:frame];  
       [self.view addSubview:videoView];  
     }  
     [videoView loadHTMLString:html baseURL:nil];  
    }  
-(void)embeddeYouTube:(NSString*)url帧:(CGRect)帧{
NSString*embedHTML=@“\
\ 
\ 
正文{
背景色:透明;\
颜色:白色;\
}\ 
\ 
\ 
\ 
";  
NSString*html=[NSString stringWithFormat:embedHTML,url,frame.size.width,frame.size.height];
如果(videoView==nil){
videoView=[[UIWebView alloc]initWithFrame:frame];
[self.view addSubview:videoView];
}  
[videoView loadHTMLString:html baseURL:nil];
}  

我马上就要下班了,所以我必须快速键入这个答案

我发现解决这个问题的一个方法是刷新正在查看的页面的缓存,我没有一个可靠的解决方案,但我上周提出了一个临时的解决方案,这可以通过在html标题中创建指向css文件的链接来实现

创建一个refresh.css文件很重要,但是要将其留空

现在使用javascript或jQuery如果您已经链接了它,请使用

。删除

在id刷新缓存上,在页面加载时,在页面加载时删除指向空文件的标题中的链接


这将刷新你的浏览器缓存,希望这有帮助

我也面临同样的问题。你解决了吗?这里也是。有什么消息吗?仍然打破了限制:(