全屏播放视频时,UIWebView突破了约束(Xcode 6) [英] UIWebView breaking constraint when playing a video in fullscreen (Xcode 6)

查看:78
本文介绍了全屏播放视频时,UIWebView突破了约束(Xcode 6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个YouTube频道更新一个iOS应用.在以前的版本(使用Xcode 5的iOS 7)中,我曾经将youtube iFrame嵌入UIWebView中,并且一切正常.

I'm updating an iOS app for an YouTube channel. In the previous version (iOS 7 using Xcode 5), I used to embed youtube iFrame in a UIWebView and everything would work just fine.

但是,在使用Xcode 6的iOS 8中,每次播放Youtube视频并使其全屏显示时,我的UIWebView约束都会中断,并且UIWebView会重新放置在Controller中(通常在屏幕上会升高10点).

However, in iOS 8 using Xcode 6, every time I play a Youtube video and it goes full screen, my UIWebView constraints break and UIWebView gets relocated in my Controller (usually goes 10 points up in the screen).

我已尝试更改约束,但似乎与设置什么约束都没有关系,当播放器全屏播放时,约束最终会中断.

I've tried to change the constraints but it seems that doesn't matter what constraint I set up, it will eventually break when the player goes full screen.

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

Here's the html code used to embed YouTube iframe:

- (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];

}

由于日志很大,因此将其粘贴到pastebin中: http://pastebin.com/z4zyq7Hs

Since the log is huge, I've pasted it in pastebin: http://pastebin.com/z4zyq7Hs

谢谢:)

推荐答案

我遇到了同样的问题.但是,尽管(使用Xcode 6.1),我没有遇到重定位问题,只有一堆约束中断日志.

I had same problem. But, I do not experience relocation problem though (using Xcode 6.1), only bunch of constraint breaking logs.

我测试过的东西仍然无法正常工作: -删除所有Web视图及其子视图的约束并将setTranslatesAutoresizingMaskIntoConstraints设置为YES -将UIWebview与更新,更快的UIWebview WKWebview交换

What I tested that still cannot work: - remove constraint and setTranslatesAutoresizingMaskIntoConstraints to YES for all the webview and its subview - swap UIWebview with WKWebview, the newer and faster UIWebview

我还测试了播放Dailymotion视频的过程,它也有相同的问题,因此我怀疑这是UIWebview的MediaPlayer视图上的更多问题.

I also test playing Dailymotion video and it also has same problem, so I suspect this is more the problem on MediaPlayer views of UIWebview.

这篇关于全屏播放视频时,UIWebView突破了约束(Xcode 6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆