Note that there are some explanatory texts on larger screens.

plurals
  1. POYouTube video playback broken on iOS6 (works fine on iOS5)
    primarykey
    data
    text
    <p>In my app, I have a button which, when pressed, lets you watch a youtube video (a movie trailer). Within the app, without launching safari. Below you can see a code snippet. This code works pefrectly fine under iOS5. However, in iOS 6, the UIButton in findButtonInView is always nil. Any ideas what might be the reason?</p> <pre><code>youtubeWebView.delegate = self; youtubeWebView.backgroundColor = [UIColor clearColor]; NSString* embedHTML = @" &lt;html&gt;&lt;head&gt; &lt;style type=\"text/css\"&gt; body {background-color: transparent; color: white; }&lt;/style&gt;&lt;/head&gt;&lt;body style=\"margin:0\"&gt;&lt;embed id=\"yt\" src=\"%@?version=3&amp;app=youtube_gdata\" type=\"application/x-shockwave-flash\"width=\"%0.0f\" height=\"%0.0f\"&gt;&lt;/embed&gt;&lt;/body&gt;&lt;/html&gt;"; NSURL *movieTrailer; if(tmdbMovie) movieTrailer = tmdbMovie.trailer; else movieTrailer = [NSURL URLWithString:movie.trailerURLString]; NSString *html = [NSString stringWithFormat:embedHTML, movieTrailer, youtubeWebView.frame.size.width, youtubeWebView.frame.size.height]; [youtubeWebView loadHTMLString:html baseURL:nil]; [self addSubview:youtubeWebView]; - (void)webViewDidFinishLoad:(UIWebView *)_webView { isWatchTrailerBusy = NO; [manager displayNetworkActivityIndicator:NO]; //stop the activity indicator and enable the button UIButton *b = [self findButtonInView:_webView]; //TODO this returns null in case of iOS 6, redirect to the youtube app if(b == nil) { NSURL *movieTrailer; if(tmdbMovie) { movieTrailer = tmdbMovie.trailer; } else { movieTrailer = [NSURL URLWithString:movie.trailerURLString]; } [[UIApplication sharedApplication] openURL:movieTrailer]; } else { [b sendActionsForControlEvents:UIControlEventTouchUpInside]; } } - (UIButton *)findButtonInView:(UIView *)view { UIButton *button = nil; if ([view isMemberOfClass:[UIButton class]]) { return (UIButton *)view; } if (view.subviews &amp;&amp; [view.subviews count] &gt; 0) { for (UIView *subview in view.subviews) { button = [self findButtonInView:subview]; if (button) return button; } } return button; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload