Tuesday 11 November 2014

Jogendra Singh

In iOS UIWebView create / make in Swift / iOS Sdk



How to create UIWebview programmatically create in swift and iOS 8 .


In this tutorial going to learn about UIWebview :-   

Some times we need to open some url or load some html content in our application

Creating UIWebview 
override func viewDidLoad() {
    super.viewDidLoad()
    let webV:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))
    webV.loadRequest(NSURLRequest(URL: NSURL(string: "http://www.jogendra.com")))
    webV.delegate = self;
    self.view.addSubview(webV)
}

How to use UIWebview delegate in swift language

First need to you take delegate in your header file

class myViewController: UIViewController, UIWebViewDelegate 

Now need to add delegate functions on UIWebview .. 


func webView(webView: UIWebView!, didFailLoadWithError error: NSError!) {
    print("Webview fail with error \(error)");
}

func webView(webView: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool {
    return true;
}

func webViewDidStartLoad(webView: UIWebView!) {
    print("Webview started Loading")
}

func webViewDidFinishLoad(webView: UIWebView!) {
    print("Webview did finish load")
}


Thanks for Visit  , Also can visit on My blog Facebook page iPhone & iPad Application Development Help World and also can visit Google+

Jogendra Singh

About Jogendra Singh -

I'm Founder of Jogendra.Com. I love to share my bright ideas with the whole blogging community. I'm a good iPhone Application Developer. Apart from Blogging, I love to play Cricket and mobile games (Clash of clans).

Subscribe to this Blog via Email :