How to implement a webview in Xamarin iOS.

Web View, on the other hand, is a handy component to load web content. In some cases, you want to display a single web page locally in your app or let users access external web pages within your app. You can simply embed the Web View object in your app and send it a request to load the web content.
We just add a single web view in our application, when this tutorial finish it will look like:
Let’s Start:
Create a new solution, select C#->iOS->Unified API->iPhone and Single View Application, give it name “SampleWebView.iOS”.
Now go to storyboard file and drag and drop WebView control from toolbox. And give name of WebView control as “webView”.
Now go to the SampleWebView.iOSViewController.cs file and write below code into ViewDidLoad method:
1 2 3 4 5 6 |
public override void ViewDidLoad () { base.ViewDidLoad (); string url = "http://google.com"; webVIew.LoadRequest(new NSUrlRequest(new NSUrl(url))); } |
Now build and run the app and when application opens it automatically transfer to google.com in WebView.
Leave a Reply