Saturday 24 June 2017

Create UIWebView Programmatically and Load Webpage Using NSURL

  1. class ViewController: UIViewController, UIWebViewDelegate {
  2. override func viewDidLoad() {
  3. super.viewDidLoad()
  4. // Do any additional setup after loading the view, typically from a nib.
  5. let myWebView:UIWebView = UIWebView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height))
  6. self.view.addSubview(myWebView)
  7. myWebView.delegate = self
  8. //1. Load web site into my web view
  9. let myURL = URL(string: "http://www.swiftdeveloperblog.com")
  10. let myURLRequest:URLRequest = URLRequest(url: myURL!)
  11. myWebView.loadRequest(myURLRequest)
  12. }

No comments:

Post a Comment

Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...