当进入全屏时,嵌入在UIWebView中的Youtube会导致iPad崩溃 [英] Youtube embedded in UIWebView causes crash on iPad when entering full screen

查看:156
本文介绍了当进入全屏时,嵌入在UIWebView中的Youtube会导致iPad崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用这种技术,并这个Youtube SDK博客文章在一个通用应用程序中。 iPhone版本使用相同的代码,工作正常。
在iPad上嵌入了视频,并且它以嵌入的形式播放得很好,但只要点击全屏按钮,应用程序就会崩溃(按钮不响应,设备不会旋转)。来自Youtube视频的音乐一直在播放。

I'm trying to embed a Youtube video using a mixture of this technique, and this Youtube SDK blog post in a universal app. The iPhone version, using the same code, works fine. On the iPad the video does embed, and it plays fine in it's embedded form, but as soon as you tap the full screen button the app crashes (buttons do not respond, the device does not rotate). The music from the Youtube video keeps playing.

没有记录错误消息,但应用确实注册为'Paused'或挂在xCode中。每次崩溃com.apple.libdispatch-manager都在线程2.问我问题,我会给你更多关于错误的信息,但我不知道从哪里开始。

There is no error message logged but the app does register as 'Paused' or hung in xCode. Every time it crashes com.apple.libdispatch-manager is on thread 2. Ask me questions and I'll give you more information about the error, but I'm not sure where to start.

我试过:


  • 更改UIWebView框架的大小

  • UIWebView位于UIScrollView中,但如果我将其从滚动视图中删除并将其添加到视图中,则问题是相同的。

  • 更改视频

  • 更改我在UIWebView中使用的html ,没有结果

  • 将youtube链接的格式从?v = uniqueID更改为/ v / uniqueID

  • 检查呈现视图是rootviewcontroller(它是,但视频嵌入模态,这不是rootview控制器)。

  • changing the size of the UIWebView frame
  • the UIWebView is in a UIScrollView, but if I take it out of the scrollview and add it to the view the problem is identical.
  • changing the video
  • changing the html that I use in the UIWebView from this to this, with no result
  • changing the format of the youtube link from ?v=uniqueID to /v/uniqueID
  • checking the presenting view is the rootviewcontroller (it is, but the video is embedded in a modal, which is not the rootviewcontroller).

我正在为iOS 5.1构建,如果在iOS6上运行则不会发生这种情况。

I am building for iOS 5.1, this doesn't happen if running on iOS6.

嵌入视频的视图是模态的,包括手机和iPad。应用程序中没有任何hackery或不寻常的事情发生。

The View that the video is embedded in is modal, both on the phone and the iPad. There's no hackery or unusual things happening in the app.

似乎有人谈论Evernote的应用程序有类似的问题,但我不知道它是否相关。

There seems to be talk of Evernote's app having a similar problem, but I don't know if it is related or not.

供您参考,这里是YouTubeView子类(它是UIWebView的子类):

For your reference, here is the YouTubeView subclass (which subclasses UIWebView):

- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
{
    if (self = [super init]) 
    {
        // Create webview with requested frame size
        self = [[YouTubeView alloc] initWithFrame:frame];

// HTML to embed YouTube video
//      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>";

        NSString *youTubeVideoHTML = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = %0.0f\"/></head><body style=\"background:#FFF;margin-top:0px;margin-left:0px\"><div><object width=\"%0.0f\" height=\"%0.0f\"><param name=\"movie\" value=\"%@\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"%@\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"%0.0f\" height=\"%0.0f\"></embed></object></div></body></html>";

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

        NSLog(@"html:\n %@", youTubeVideoHTML);

        NSString *html = [NSString stringWithFormat:youTubeVideoHTML, frame.size.width, frame.size.width, frame.size.height, urlString, urlString, frame.size.width, frame.size.height];

        NSLog(@"html:\n %@", html);

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

    return self;
}


推荐答案

iOS 5.0上的模态视图iOS 5.1是导致全屏视频AFAIK崩溃的问题。他们刚刚更改了iOS版本中的视图层次结构( parentViewController presentsViewController ),这就是后果。我很久以前就问过这里,还有一个问题是在哪里,但仍然没有人知道该怎么做。

Modal view on iOS 5.0 and iOS 5.1 is the problem that causes crash on full screen video, AFAIK. They just changed hierarchy of views in that version of iOS (parentViewController and presentingViewController) and that is the aftermath. I asked about it long time ago here and one more same question is here and still no one knows what to do.

首先,他们将其修复为6.0,我猜,这很好。

First of all, they fixed it in 6.0, I guess, that's good.

对于5.1,我们改变了设计并避免模态视图。如果可能的话,请这样做。

For 5.1 we changed design a little and avoided modal view. Do it, if it is possible in your situation.

这篇关于当进入全屏时,嵌入在UIWebView中的Youtube会导致iPad崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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