uiwebviewswift2xcode7.2

create a webview in a view controller to open a url with swift 2 xcode 7.2


I have created a viewcontroller called communityViewController and connected it to its class with the same name. Then I added a webview in man.storyboard. How do i configure it now in the .swift file?


Solution

  • class communityViewController:UIViewController {
    
      @IBOutlet weak var webView: UIWebView!
      override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let url = NSURL (string: "http://example.de/");
        let requestObj = NSURLRequest(URL: url!);
        webView.loadRequest(requestObj);
      }
    }