iOS 8 video YouTube incorporer

Je suis confronté à des problèmes que je n'arrive pas à comprendre.

J'ai ce code qui fonctionne parfaitement dans Xcode 5 avec iOS 7:

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CGFloat width = self.view.frame.size.width; CGFloat height = self.view.frame.size.height; UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; NSSsortingng* embedHTML = @"\ <html><head><meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; user-scalable=0;\"/>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: black;\ }\ </style>\ </head><body style=\"margin:0;\">\ <embed id=\"yt\" src=\"https://www.youtube.com/v/M7lc1UVf-VE?hd=1\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSSsortingng *html = [NSSsortingng ssortingngWithFormat:embedHTML, width, height]; [webview loadHTMLSsortingng:html baseURL:nil]; [self.view addSubview:webview]; } 

Lorsque je construis le même code dans Xcode 6 pour iOS 8, la video s'affiche dans le webview mais est trop petite.

Quelqu'un peut-il expliquer ce qui se passe ici et comment je pourrais surmonter cela?

J'ai eu le même problème, je résous d'utiliser cette solution

https://developers.google.com/youtube/v3/guides/ios_youtube_helper

aussi dans le YTPlayerView.m (~ line: 610) essayez ceci:

 [playerParams setValue:[NSSsortingng ssortingngWithFormat: @"%0.00f", self.frame.size.height] forKey:@"height"]; // [playerParams setValue:@"100%" forKey:@"height"]; [playerParams setValue:[NSSsortingng ssortingngWithFormat: @"%0.00f", self.frame.size.width] forKey:@"width"]; // [playerParams setValue:@"100%" forKey:@"width"]; 

J'espère que cette aide

J'ai travaillé sur cela pendant un moment et j'ai trouvé une solution qui fonctionne étonnamment pour mes objectives. Ce qui se passait dans mon cas, c'est pour une raison quelconque que l'iFrame utilisait un rembourrage qui devait être jeté.

Il est également important de noter que si vous incluez youtube.com en tant qu'URL de base, il se chargera beaucoup plus rapidement.

Faites un UIWebView dans votre storyboard et connectez le @property à celui-ci, puis faites reference ci-dessous.

  CGFloat height = self.webView.frame.size.height; CGFloat width = self.webView.frame.size.width; NSSsortingng *youTubeVideoCode = @"dQw4w9WgXcQ"; NSSsortingng *embedHTML = @"<iframe width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" style=\"margin:-8px;padding:0;\" allowfullscreen></iframe>"; NSSsortingng *html = [NSSsortingng ssortingngWithFormat:embedHTML, width, height, youTubeVideoCode]; self.webView.scrollView.bounces = NO; [self.webView loadHTMLSsortingng:html baseURL:[NSURL URLWithSsortingng:@"http://www.youtube.com"]];