【问题标题】:Youtube player in UIWebView in ModalViewControllerModalViewController 中 UIWebView 中的 Youtube 播放器
【发布时间】:2023-03-17 11:25:01
【问题描述】:

我正在开发一个针对 > iOS 4 的应用程序。在这个应用程序中,我将 UIWebView 显示为 modalView(在 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 播放器,我的模态视图控制器就会被释放并且跳回它会失败。我没有成功找到添加保留或类似内容的地方……

任何人都看到了这种情况,可以给我一个提示吗?

谢谢, 标记。

【问题讨论】:

  • 我在我的应用中也看到了这种行为......

标签: iphone uiwebview youtube modalviewcontroller


【解决方案1】:

看到这个:Reg: modifying layer that is being finalized....... [CALayer frame]: message sent to deallocated instance 0xe43c520

"modifying layer that is being finalized" 错误发生在您尝试修改处于释放过程中的 CALayer 的属性时。当我在该层的 -dealloc 方法中不小心使用访问器清除 CALayer 上的属性时,我已经看到了这种情况。

【讨论】:

    猜你喜欢
    • 2012-11-08
    • 2014-04-12
    • 1970-01-01
    • 2012-09-15
    • 2015-04-25
    • 2011-05-05
    • 2012-11-12
    • 2013-06-19
    • 1970-01-01
    相关资源
    最近更新 更多