問題描述
更新: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 出現異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!