【问题标题】:ipad camera and webview youtube video playing issueipad 相机和 webview youtube 视频播放问题
【发布时间】:2011-11-19 23:13:09
【问题描述】:

Rootviewcontroller 有一个播放 youtube 视频的 webview 它有一个相机按钮。 用户可以单击相机按钮并录制视频。 到目前为止,它的工作正常

当我关闭相机控制器并尝试在 web 视图中播放视频时,即使我尝试删除并再次添加视图,它的帧也会受到干扰。

当我关闭相机控制器而不录制视频时,它工作正常... 这是图片 播放视频的代码

 GDataEntryBase *entry2 = [[AppDelegate.feed entries] objectAtIndex:[tag intValue]];
    NSArray *contents = [[(GDataEntryYouTubeVideo *)entry2 mediaGroup] mediaContents];
   NSString *urlString=[NSURL URLWithString:[[contents objectAtIndex:0] URLString]];

    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: black;\
    color: black;\
    }\
    </style>\
    </head><body style=\"margin:0\"><div>\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"736\" height=\"571\"></embed></div>\
    </body></html>";
    NSString *html = [NSString stringWithFormat:embedHTML, urlString, webplay.frame.size .width, webplay.frame.size.height];
    NSLog(@"html=%@",html);
        [webplay loadHTMLString:html baseURL:nil];

【问题讨论】:

  • 检查其自动调整大小属性
  • 我确实检查过,但这是层问题我使用 hittest 来解决这个问题

标签: iphone ipad ios4 uiwebview uiimagepickercontroller


【解决方案1】:

您需要“&lt;div&gt;”标签吗?尝试删除它们,看看会发生什么。

另外,下面的这个链接对我有用,它提供了很好的示例代码。我改变了使用 YouTube 的方式来适应这个模型,并且能够轻松地构建一个由单元格中的 youtube 链接填充的表格。当您点击单元格时,视频将在一帧内播放。

http://iosdevelopertips.com/video/display-youtube-videos-without-exiting-your-application.html

希望这会有所帮助。

【讨论】:

  • 我确实检查过,但这是层问题我使用 hittest 来解决这个问题
【解决方案2】:

我确实检查了,但这是层问题我使用命中测试来解决这个问题。

这是一个显示如何使用hit test的链接

【讨论】:

  • 添加更多详细信息以使此答案对其他人也有用
【解决方案3】:
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];


    [self viewDidLoad];
// or if u write code in your viewdidapper method than

    [self viewDidAppear:NO];

}

您可以在单击取消按钮时再次加载整个视图。

【讨论】:

  • 我确实检查过,但这是层问题我使用 hittest 来解决这个问题
【解决方案4】:

使用 webviewcontroller 播放电影会带来很多问题(例如旋转)。使用专门的电影类总是一个更好的主意。

如果您出于某种原因仍需要使用 webview,我通过以下方式发现了这一点: - 在临时变量中设置 RootViewController - 将 RootViewController 设置为 nil - 使用存储变量的内容再次恢复 RootViewController

整个视图堆栈被重新初始化,并且可以解决我在旋转变得怪异时遇到的很多问题。 Wo 知道“黑客”也可能对您有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-14
    • 2012-06-07
    • 1970-01-01
    • 2011-01-18
    • 2013-07-13
    • 2014-02-10
    • 2013-11-19
    • 2022-01-04
    相关资源
    最近更新 更多