system21 system21 - 4 months ago 50
iOS Question

Create UIwebview reload + goback/forward button programmatically

How do Create

UIwebview
reload +
goback/forward
button programmatically.

How do i call the following functions

func reload()
func goBack()
func goForward()


updated current code :

import UIKit

class webviewViewController: UIViewController {
@IBOutlet var webview: UIWebView!

@IBAction func reload(sender: UIBarButtonItem) {
webview.reload()
}

override func viewDidLoad() {
super.viewDidLoad()

let url = NSURL (string: "http://www.google.com");
let requestObj = NSURLRequest(URL: url!);
webview.loadRequest(requestObj);
}
}

Answer

Here is answer

@IBAction func reload(sender: UIBarButtonItem) {

             webview.reload()

        }

@IBAction func back(sender: UIBarButtonItem) {

             webview.goBack()

        }
@IBAction func forward(sender: UIBarButtonItem) {

             webview.goForward()

        }