Sandeep Chaudhary
Sandeep Chaudhary

Reputation: 68

Move to backward and forward on button click in uiwebview

hi i want to move to next page of html file on next button click and previous button click.

NSString *htmlPath   = [[NSBundle mainBundle] pathForResource:@"opening" ofType:@"html"];
NSData *htmlData     = [NSData dataWithContentsOfFile:htmlPath];
NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];

[self.webView loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];

Upvotes: 1

Views: 212

Answers (1)

iphonic
iphonic

Reputation: 12719

To go Forward, Backward you just need to call these default UIWebview methods

-(IBAction)goBackAction{
    if(self.webView.canGoBack){
      [self.webView goBack];
    }
}

-(IBAction)goForwardAction{
    if(self.webView.canGoForward){
      [self.webView goForward];
    }
}

Hope this helps.

Upvotes: 2

Related Questions