iOS5:在模态 UIViewController 中播放 Youtube 视频时 U

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 出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)