Search code examples
iosuiwebviewnsurlconnectionnsurlrequestuiwebviewdelegate

Different URL Load with shouldStartLoadWithRequest


i am currently using http://something.com this link inside the uiwebview for my ios app. In this dummy website there is another link. I wanna open native ios camera screen after clicking this link. Right now i am able to open cam only for http://something.com this url. But i need to open the cam by clicking another link inside this http://something.com. When i click the other link url is changing to ``http://something.com\webapp`. So how can i make it work? Any ideas?

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;

NSRange range = [urlString rangeOfString:@"http://something.com"];
if (range.location != NSNotFound) {
   [self showCamera]; //camera starts
    return YES;
} else {
    return NO;
    }

Solution

  • This should do the trick:

    if ([request.URL.absoluteString containsString:@"webapp"]) {
       [self showCamera];
       return NO;
    } else {
       return YES;
    }