0
Good morning, everyone
I can easily upload a web page to a Uiwebview with the following Swift code:
import UIKit
class ConteudoOnlineViewController: UIViewController {
@IBOutlet weak var pagina: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
pagina.delegate = self as? UIWebViewDelegate
if let url = URL(string: "http://www.meusite.com.br/login.aspx") {
let request = URLRequest(url: url)
pagina.loadRequest(request)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
However my site has login page and I created a validation to access directly by passing a token, it happens that now I can not load this page in Uiwebview, just nothing appears. Could someone give me an idea of what I should do??
import UIKit
class ConteudoOnlineViewController: UIViewController {
@IBOutlet weak var pagina: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
pagina.delegate = self as? UIWebViewDelegate
if let url = URL(string: "http://www.meusite.com.br/login.aspx?token=6D5C6A4BF468D43ABD521A3C9D3469C3") {
let request = URLRequest(url: url)
pagina.loadRequest(request)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Rafael Leão thanks for your comment, but I’ve done it to be able to access links in http but I do not get success in this case, it opens any link but when I try this way passing a token to login directly in the system nothing appears in the webview
– Julio Figueiredo
Then I suggest implementing Uiwebviewdelegate methods and see which ones are called
– Rafael Leão