I am currently using ChildBrowser in phoneapp to open a website. However, I would like to open all external links of this website to open in Safari.
I do not have control over the source of this website.
My understanding is that I have to modify ChildBrowser to open all links starting with "http" in Safari.
I can't exactly read Objective-C, but I believe the code below is relevant.
- (void)loadURL:(NSString*)url
{
NSLog(@"Opening Url : %@",url);
if( [url hasSuffix:@".png" ] ||
[url hasSuffix:@".jpg" ] ||
[url hasSuffix:@".jpeg" ] ||
[url hasSuffix:@".bmp" ] ||
[url hasSuffix:@".gif" ] )
{
[ imageURL release ];
imageURL = [url copy];
isImage = YES;
NSString* htmlText = @"<html><body style='background-color:#333;margin:0px;padding:0px;'><img style='min-height:200px;margin:0px;padding:0px;width:100%;height:auto;' alt='' src='IMGSRC'/></body></html>";
htmlText = [ htmlText stringByReplacingOccurrencesOfString:@"IMGSRC" withString:url ];
[webView loadHTMLString:htmlText baseURL:[NSURL URLWithString:@""]];
}
else if ( [url hasPrefix:@"http" ])
{
//I have added in this else if.
}
else
{
imageURL = @"";
isImage = NO;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[webView loadRequest:request];
}
webView.hidden = NO;
}
Any advice?