J Jefferson
J Jefferson

Reputation: 21

How do I add navigations to an iOS UIWebView?

I'm very new to iOS programming and am relatively unfamiliar with how swift works. I've been trying to make a basic app that displays a webpage and I need to a navigation bar (preferably at the bottom) that has at least a back button and forward button. My storyboard just contains a fullsize webview.

Here is my View Controller

import UIKit
import WebKit

class ViewController: UIViewController {

    @IBOutlet weak var WebView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let url = URL(string: "https://71republic.com/")
        let request = URLRequest(url: url!)
        WebView.load(request)
        // Do any additional setup after loading the view, typically from a nib.
    }
}

Any help would be appreciated

Upvotes: 1

Views: 101

Answers (2)

Arie Pinto
Arie Pinto

Reputation: 1292

This is what your looking for my friend : How To Create A Web Browser In Xcode 8 (Swift 3)

Upvotes: 0

Fkzm
Fkzm

Reputation: 220

You have two options: 1st: If you want navigation bar at the bottom, drag navigation bar from items to bottom of your view controller.

2nd: Put your view controller into navigation path. You should add Navigation controller into your storyboard and make your controller root view controller.

For 'back' button you should have previous page and navigate to your current page with segue. And for 'Next' you should navigate your current page to next page with segue.

Read about segue, navigation bar, navigation controller.

Upvotes: 1

Related Questions