UIWebView example in iOS swift
How to use UIWebView in iOS and swift language
WebView is very easy t use in ios because of ios provide UIWebView. you can find UiWebView in object library .webview is use for load HTML page in ios application.If you load a HTTPS:// URL is apple is very easy to support this type of URL but if you like to load the only HTTP:// apple not support because the only HTTP:// is not a secure URL. If you like to support this type of URL this adds two permission
if you like more understanding watch my video tutorial
Step - 1
create your new Xcode project if don't know how to create Xcode project
Step - 2
you are going to your object library and find UIWebView. UIWebView is drag and drop in your storyboard.
Stp - 3
create an outlet of this web view.
@IBOutlet weak var webview: UIWebView!
Step - 4
write this code in viewDidLoad()
let url = "https://www.google.co.in"
let urlobject = NSURL (string: url)
let request = NSURLRequest(URL: urlobject!)
webview.loadRequest(request)
Note:
https:// URL ios support very easily because of https is very secure URL. if like to support the only HTTP:// URL than follow this step
first open your Info.plist file and add two permission
App Transport Security Settings
Allow Arbitrary Loads = YES
code is same only change is HTTPS to HTTP
let url = "http://myios18.blogspot.in/"
let urlobject = NSURL (string: url)
let request = NSURLRequest(URL: urlobject!)
webview.loadRequest(request)
if you are more understanding about variable open this line
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment