I get an error when I press a button on the sideBar stopping here:
webView.scalesPageToFit = true
webView.loadRequest(request)
I would like to ask help to solve the problem.
Below is my code of ViewController.swift
import UIKit
class ViewController: UIViewController, UISearchBarDelegate {
@IBOutlet weak var searchBar: UISearchBar!
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://www.apple.com")
let request = NSURLRequest(URL: url!)
webView.scalesPageToFit = true
webView.loadRequest(request)
}
func searchBarSearchButtonClicked(searchBar: UISearchBar! {
caricaUrl(searchBar.text)
}
func caricaUrl(url: String) {
let url = NSURL(string: "http://www.google.com/search?q=" + "\(url)")
let request = NSURLRequest(URL: url!)
webView.scalesPageToFit = true
webView.loadRequest(request)
}
func didReceiveMemoryWaarning() {
super.didReceiveMemoryWarning()
}
@IBAction func onBurger() {
(tabBarController as TabBarController).sidebar.showInViewController(self, animated: true)
}
}