0

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;
    }
DDDDD
  • 55
  • 7
  • You can check the other link is present or not using "[urlString containsString:@"your other url"]".If it is present you can open camera."containsString" is available from iOS 8.0 – Sanman Jun 02 '16 at 12:26
  • Can you give me an example how will i open another link `http://something.com/webapp` that located inside `http://something.com` by using containsString? @sanman – DDDDD Jun 02 '16 at 12:34
  • I meant you can check string using "containsString" that you are being redirected to.Instead of using NSRange.i.e after clicking on button.Check richmond's answer. – Sanman Jun 02 '16 at 12:45

1 Answers1

0

This should do the trick:

if ([request.URL.absoluteString containsString:@"webapp"]) {
   [self showCamera];
   return NO;
} else {
   return YES;
}
Richmond Watkins
  • 1,342
  • 9
  • 17