I am creating an application in xcode using the Cordova / phonegap framework for ios, which displays some html that has YouTube player code embedded in it. IOS seems to redirect the user to the youtube app when it hits this player. The following code worked in cordov 1.5.0, but in 1.6.1 it does not look. Any ideas why or what needs to be changed to make it work?
to stop youtube opening and links to yourself.
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
NSString* urlString = [url absoluteString];
if([urlString rangeOfString:@"http://www.youtube.com/embed"].location != NSNotFound) {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
else if (([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"])) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
David source
share