uiwebview - iOS webview load another url with Safari -


i making app ios, use uiwebview load website in app. want links (besides website) open in safari. read many articles , tried many different suggestion still can't make it.

i not familiar in coding, use xcode 6.3.2

here code of viewcontroller.m:

#import "viewcontroller.h"  @interface viewcontroller ()  @end  @implementation viewcontroller  - (void)viewdidload {     [super viewdidload];     nsstring *fullurl = @"http://www.mywebsite.com";     nsurl *url = [nsurl urlwithstring:fullurl];     nsurlrequest *requestobj = [nsurlrequest requestwithurl:url];     [_viewweb loadrequest:requestobj]; }   - (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype {      // check if click event , other criteria determining if want launch safari.     if (navigationtype == uiwebviewnavigationtypelinkclicked         && [ [ request.url scheme ] isequaltostring: @"http" ] ) {         [[uiapplication sharedapplication] openurl:request.url];      // return false indicate uiwebview not navigate linked target     return false; }  // return true uiwebview loads link target return true; }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  @end 

please help

update method

- (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { 

in like:

- (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { nsstring *requesturl = [[request url] absolutestring];      if ([requesturl rangeofstring:@"mydomain.com"].location != nsnotfound) {         [[uiapplication sharedapplication] openurl:[request url]];         return no;     }     return yes; } 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -