Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
I want to listen the webview and do something with the opened url. I do this with this delegate method.

Code:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    NSString *currentLink = request.URL.absoluteString;
  
  
    if ([currentLink containsString:@"close"]) {      
        [self closeTheAdvView];
    }
  
    return YES;
}
1- i try to click a button inside the webview. It works in iOS9 but not in iOS8. How can i make it clickable in iOS 8 as well ?

2- when i click a button inside the webview it opens a new url(e.g:close.com). when i get that link then i will hide the webview. but when i click the button then it gives an error in log screen like
-canOpenURL: failed for URL: "" - error: "Invalid input URL"
what can be wrong here ?
 
Last edited:
I don't see any call to canOpenURL: in the code you show. You should probably return NO if you don't want this 'close' link to be opened. 'close.com' is not a URL. 'http://www.close.com' is a URL. Usually this kind of thing is done with custom schemes. 'close://me' is a valid URL that your code can scan for in the delegate callback.

The error shows the empty string as the URL, which of course it cannot open. I don't know how that happens though.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.