JWSWebViewSample created sample code for UIWebView and WKWebView with swift and objective-c.
This is the WebView Sample source. Both UIWebView and WKWebView can be checked together.You can also check the Swift source and Objective-C source.
This is the default project swift. You can also test with objective-c by adding an objective-c source inside. Public data was managed by appdelegate.swift.
It is easy to check the execution result of UIWebView and WKWebView.
An example of using objective-c in swift, and an example of using the swift source in objective-c.
structure | objective-c | swift |
---|---|---|
![]() | ![]() | ![]() |
...
// Change your test URL here.
private let urlString = "http://www.github.com"
// For convenience, I created it in "appdelegate". This is whether or not "URL" is selected.
@objc var isURL:Bool = false
@objc var url:URL? {
return URL(string: urlString)
}
...
objective-c
sample.html
Swift
Packaging, Defines Module : YES | Import “yourprojectname-Swift.h” |
---|---|
![]() | ![]() |
Objective-C, Bridging Header Setting
iPhone X Sample View 1 | iPhone X Sample View 2 |
---|---|
![]() | ![]() |