objective-c - Youtube 和模态视图

标签 objective-c youtube modalviewcontroller presentmodalviewcontroller

我有一个显然是基本的问题。我有一个应用程序,它有一个多媒体部分,里面有视频(Youtube 或 Ted)。

当您选择一个视频 (TableView) 时,我会打开一个带有一点描述的模态视图,如果它是一个 Youtube 视频,则会打开一个 web View ,您必须单击它才能打开视频。在另一种情况下,我使用 MPMovieController。

我遇到的问题是在 Youtube 视频中。当我关闭播放器时,我的模态视图也关闭了,并且使用模态视图的应用程序的其余部分不起作用(它不会打开模态视图)。

这里是描述 View 的代码:

- (void)viewDidLoad{

[super viewDidLoad];

NSRange range = [sendVideo rangeOfString:@"youtube"];


if(range.length>0){


    NSString *htmlString =[NSString stringWithFormat:@"<html><head>"
                           "<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>"
                           "<body style=\"background:#F00;margin-top:0px;margin-left:0px\">"
                           "<div><object width=\"212\" height=\"172\">"
                           "<param name=\"movie\" value=\"%@\"></param>"
                           "<param name=\"wmode\" value=\"transparent\"></param>"
                           "<embed src=\"%@\""
                           "type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"212\" height=\"172\"></embed>"
                           "</object></div></body></html>",sendVideo,sendVideo];



    [youtube loadHTMLString:htmlString baseURL:nil];



}

else

{...

这是我用来在 TableView 中选择视频的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


if(videosContenido ==YES){



    VerDetalles *vd = [[[VerDetalles alloc]initWithNibName:@"VerDetalles"

                                                   bundle:nil]autorelease];



    vd.sendTitle = [aux2 objectAtIndex:[indexPath row]];

    vd.sendDesc = [aux6 objectAtIndex:[indexPath row]];

    vd.sendVideo = [aux4 objectAtIndex:[indexPath row]];

    UINavigationController *navController= [[[UINavigationController alloc]

                                            initWithRootViewController:vd]autorelease];

    if(navController){

        navController.modalPresentationStyle = UIModalPresentationFormSheet;

        navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    }else {

        [tableView deselectRowAtIndexPath:indexPath animated:YES];

    }

    [self presentModalViewController:navController  animated:YES];  

}

最佳答案

我有完全相同的问题。我注意到没有在我的应用程序委托(delegate)中设置 window.rootViewController 属性可以解决问题。 (只需调用 [window addSubview:rootViewController.view])。但是,在 iOS 6 中,当没有设置窗口的 rootViewController 时,自动旋转不起作用。

关于objective-c - Youtube 和模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9735247/

相关文章:

ios - 模态视图 Controller 从自定义单元格选择问题中分离 - iOS 7

objective-c - UIPageControl 在 IOS7 中不支持 UIImageView

iphone - 如何在应用程序图标下的应用程序名称中设置小图像符号?

c - 是否可以使用 NSLog C 结构(如 CGRect 或 CGPoint)?

facebook - 如何在 Facebook 上分享 YouTube 视频并在 iPad 上运行?

android - 如何在YouTube Player API中播放多个视频?

objective-c - 如何将char *转换为float xcode

Wordpress:自动从推文和 YouTube 视频创建博客文章?

ios - 在 iOS 13 全屏中呈现模式

ios - 状态栏和 UI 方向不匹配