qua*_*tum 9 youtube iphone uiwebview
在我的iPhone应用程序中,我将在主屏幕上呈现一个模态视图控制器,其中UIWebView使用以下内容显示"内嵌"嵌入式YouTube视频:
UIWebView *youTubeWV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 220)];
[youTubeWV loadRequest:[NSURLRequest requestWithURL:sourceURL]];
//NSString *youTubeVideoHTML = [NSString stringWithFormat:@"<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=CadgUJRZfEE\" type=\"application/x-shockwave-flash\" width=\"320\" height=\"220\"></embed>"];
NSString *youTubeVideoHTML =@"<html><head>"
"<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 220\"/></head>"
"<body style=\"background:#FFFFF;margin-top:0px;margin-left:0px\">"
"<div><object width=\"320\" height=\"220\">"
"<param name=\"wmode\" value=\"transparent\"></param>"
"<embed src=\"http://www.youtube.com/v/W-nzUoaI2Ss?f=user_favorites&app=youtube_gdata\""
"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"220\"></embed>"
"</object></div></body></html>";
[youTubeWV loadHTMLString:youTubeVideoHTML baseURL:nil];
[self.view addSubview:youTubeWV];
Run Code Online (Sandbox Code Playgroud)
在显示的模态视图"quicktime player"中,视频显示没有问题.然而,当我点击"完成"关闭第二个模态时,我被踢回到第一个屏幕,绕过我的第一个模态视图.在我的主屏幕中,现在所有按钮都不起作用.奇怪!
更新:我从我的主屏幕中删除了模态转换,并将其改为"pushViewController",现在一切正常.所以这是YouTube播放器同时解散2个模态的问题.怎么解决这个问题?
有任何想法吗?
Isa*_*ros 12
我不确定但似乎在按下"完成"按钮并且播放器关闭后,控件将返回到根视图控制器,在您的情况下,这是您的第一个屏幕.
对于我的应用程序中的exaple我有一个UITabBarController作为我的rootViewController,在我的AppDelegate中我有这样的东西:
self.window.rootViewController = self.myTabBarController;
Run Code Online (Sandbox Code Playgroud)
这就是为什么在按下"完成"按钮后总是显示我的tabBarController(我的第一个屏幕)的原因.
我在演示之后解决了这个设置我的模态视图作为我的rootViewController.
在演示模态视图后尝试此操作:
MyAppDelegate *appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication] delegate];
[self presentModalViewController: myModalViewController animated: YES];
[self.appDelegate.window setRootViewController: myModalViewController];
Run Code Online (Sandbox Code Playgroud)
注意:在关闭模态视图后,您必须还原根视图控制器
就我而言:
self.appDelegate.rootViewController = self.appDelegate.myTabBarController;
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你
| 归档时间: |
|
| 查看次数: |
4175 次 |
| 最近记录: |