iOS5:在模态 UIViewController 中播放 Youtube 视频时 UIWebView 出现异常

iOS5: Exception on UIWebView in modal UIViewController playing Youtube video(iOS5:在模态 UIViewController 中播放 Youtube 视频时 UIWebView 出现异常)
本文介绍了iOS5:在模态 UIViewController 中播放 Youtube 视频时 UIWebView 出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

更新:iOS 6 beta 1 上不再出现

UPDATE: No longer occurs on iOS 6 beta 1

我目前正在使用新的 iOS 5 SDK 调整现有的 iOS 4 应用程序.在读取 Youtube 视频的模态视图控制器中显示 UIWebView 时,我发现了一个新的崩溃.

I am currently working on adapting an existing iOS 4 application with the new iOS 5 SDK. I found a new crash when presenting a UIWebView in a modal view controller that reads a Youtube video.

开始阅读视频很好,但是当我尝试将其设置为全屏时,出现以下异常:

Starting to read the video is fine, but when I try to set it in full screen, I get the following exception :

Exception: UIViewControllerHierarchyInconsistency,
child view controller:<UIViewController: 0x6aef180> 
should have parent view controller:<WebViewController: 0x6a706c0> 
but requested parent is:<MPInlineVideoViewController: 0x6ae5d40>

这是我在主视图控制器中实例化和呈现模态视图控制器的方式:

Here is how I instanciate and present my modal view controller in my main view controller :

- (IBAction)buttonReleased:(id)sender
{
    WebViewController *webVC = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
    webVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    webVC.modalPresentationStyle = UIModalPresentationPageSheet;
    [self presentModalViewController:webVC animated:YES];
}

我使用 UIModalPresentationPageSheet 作为 modalPresentationStyle,当我将此值设置为 UIModalPresentationFullScreen 时,不再出现错误.

I use the UIModalPresentationPageSheet as modalPresentationStyle, when I set this value to UIModalPresentationFullScreen, the error no longer occurs.

在我的模态 WebViewController 中,这是我加载 Youtube 视频的方式:

In my modal WebViewController, here is how I load my Youtube video :

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=bDlm3eLRut0"]]];
}

对这个问题有什么想法吗?如果需要,我可以提供一个完整的示例代码来隔离此崩溃.

Any ideas on this problem ? I can provide a full sample code that isolates this crash if needed.

谢谢!

推荐答案

我们通过基本实现我们自己的模态视图转换解决了这个问题.这实际上很容易做到.我在大约 4 小时内完成了它.

We resolved this by basically implementing our own modal view transitions. It was actually pretty easy to do; I built it in about 4 hours.

如果您以模态方式全屏显示,也可以避免崩溃.表单(表单或页面表单)是导致崩溃的原因.

You can also avoid the crash if you are presenting it modally full screen. Sheets, either form sheets or page sheets, are the causes of the crash.

这篇关于iOS5:在模态 UIViewController 中播放 Youtube 视频时 UIWebView 出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

AWS DynamoDB Batch Get Request - iOS(AWS DynamoDB 批量获取请求 - iOS)
Querying DynamoDB on non-key attributes(在非关键属性上查询 DynamoDB)
DynamoDB auto incremented ID amp; server time (iOS SDK)(DynamoDB 自动递增 ID amp;服务器时间(iOS SDK))
Where to find a clear explanation about swift alert (UIAlertController)?(哪里可以找到关于 swift alert (UIAlertController) 的清晰解释?)
Facebook Requests Dialog: Frictionless Requests in native iOS app possible?(Facebook 请求对话框:本机 iOS 应用程序中的无摩擦请求可能吗?)
dynamodb scanexpression with scan filter in objective-c(在objective-c中带有扫描过滤器的dynamodb scanexpression)