在ModalViewController中使用UIWebView播放Youtube视频

3

我正在开发一个针对 iOS 4 的应用程序。在这个应用程序中,我将 UIWebView 显示为模态视图(在一个 UIViewController 中,该视图从一个存在于 UINavigationController 中的 UITableViewController 中推出):

SettingsViewController *settings = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:settings];
[self.navigationController presentModalViewController:navController animated:YES];
[settings release];
[navController release];

这显示了一个带有UITableView的模态视图。一旦点击特定行,我的浏览器视图控制器就会被推送:

        WebBrowserViewController *vc = [[WebBrowserViewController alloc] initWithNibName:@"WebBrowserView" bundle:nil];
        [self.navigationController pushViewController:vc animated:YES];
        [vc goToUrl:@"http://www.example.com"];
        [vc release];

WebBrowserViewController内部包含一个UIWebView和一些浏览器控件(地址栏、后退和刷新按钮)。这一切都按预期工作。

问题来了: 如果网站上嵌入了YouTube视频并且点击了这些视频,那么YouTube播放器就会全屏启动。一旦我关闭了YouTube播放器(完成按钮),播放器关闭,显然我的模态视图也关闭了,然后在显示我的根视图控制器一秒钟后应用程序崩溃了。

这是控制台输出:

2011-02-24 14:52:51.109 MyApp[498:307] modifying layer that is being finalized - 0x14eda0
2011-02-24 14:52:51.113 MyApp[498:307] modifying layer that is being finalized - 0x14b590
2011-02-24 14:52:51.117 MyApp[498:307] modifying layer that is being finalized - 0x14c630
2011-02-24 14:52:51.262 MyApp[498:307] modifying layer that is being finalized - 0x14eda0
2011-02-24 14:52:51.270 MyApp[498:307] *** -[CALayer sublayers]: message sent to deallocated instance 0x178fe0

我的猜测是一旦YouTube播放器启动,我的模态视图控制器就会被释放,回到它时失败。我没有成功找到添加保留或类似内容的位置...
有人见过这种情况发生并能给我提示该怎么做吗?
谢谢, 马克。

我也在我的应用程序中看到了这种行为... - Tim Norman
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接