iOS Objective-C webview link button to webpage -


so have been looking round , can't seem find answer this. in objective-c app inside viewcontroller.m, wrapping web app in webview such:

 - (void)viewdidload {     [super viewdidload];   nsurl *url = [nsurl urlwithstring:@"https://myapp.com"]; nsurlrequest *request = [nsurlrequest requestwithurl: url]; [_webview loadrequest:request]; } 

and have followed tutorial allows me add toolbar such: enter image description here

going , forward fine, thats not want. want able have button such "login" take me https://myapp.com/signin etc. have searched can't seem find out how so.

i'm not quite sure test out in m viewcontroller.m trying:

- (ibaction)clicks:(id)sender {  nsurl *spotiurl = [nsurl urlwithstring:@"http://myapp.com/clicks"];  [[uiapplication sharedapplication] openurl:spotiurl options:@{}  completionhandler:^(bool success) {  if (success) {     nslog(@"opened url"); } }];  } 

which doesn't seem anything. please :(

the code have opens url outside of app letting ios handle opening of url. in order open url in webview, you'd have modify code this:

- (ibaction)clicks:(id)sender {     nsurl *url = [nsurl urlwithstring:@"http://myapp.com/clicks"];     nsurlrequest *request = [nsurlrequest requestwithurl:url];     [_webview loadrequest:request];     } 

Comments