I am currently having this issue with IOS app.
When I click on a URL button the UIWebView loads the correct URL in first instance however when I visit another page within same Web View Frame it stores that page to its memory. When I navigate to another button and click back to previous button it shows the page that I was previously in instead of loading the URL.
What I want to achieve is when user clicks on button the UIWebView loads the URL .
My current code:
import UIKit
class MenuViewController: UIViewController {
#IBOutlet weak var oyebWebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
oyebWebView.loadRequest(NSURLRequest(URL: NSURL(string: MenuUrl)!))
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
You can use following code it will work.
import UIKit
class MenuViewController: UIViewController {
#IBOutlet weak var oyebWebView: UIWebView!
override func viewWillAppear(animated: Bool) {
let webUrl : NSURL = NSURL(string: MenuUrl)!
let webRequest : NSURLRequest = NSURLRequest(URL: webUrl)
oyebWebView.loadRequest(webRequest);
}
override func viewDidLoad() {
// super.viewDidLoad()
//super.viewWillAppear(YES)
// self.viewDidAppear(true)
let webUrl : NSURL = NSURL(string: MenuUrl)!
let webRequest : NSURLRequest = NSURLRequest(URL: webUrl)
oyebWebView.loadRequest(webRequest);
//oyebWebView.loadRequest(NSURLRequest(URL: NSURL(string: MenuUrl)!))
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
Related
I am trying to wrap my website inside a WKWebView but an anchor with href="tel:312133" is not showing any action when clicked on it.
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let mUrl = URL(string: "https://www.example.com")
let mRequest = URLRequest(url: mUrl!)
webView.load(mRequest)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I am actually using a WKWebView in my IOS application. The url loaded successfully but when clicking on the Facebook and Twitter share buttons nothing happens. How can I solve this issue?
Here is the following code:
ViewController:
import UIKit
import WebKit
class ViewController: UIViewController,WKNavigationDelegate {
#IBOutlet var containerView : UIView! = nil
var webView = WKWebView()
override func loadView() {
super.loadView()
self.webView = WKWebView()
self.view = self.webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "https://www.examplepage.com")!
webView.load(NSURLRequest(url: url as URL) as URLRequest)
webView.allowsBackForwardNavigationGestures = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I've made in Swift a webview & in that webview there are links to ics file on the same domain of the webview. Now, when you click this link in Safari, you can perfectly add this to your calendar, but when I try this in iOS simulator, or on my device, I can't 'open' the ICS file link.
Any idea what I am doing wrong? Thanks!
This is my code:
import UIKit
class FirstViewController: UIViewController {
#IBOutlet weak var webAgenda: UIWebView!
#IBOutlet weak var activityagenda: UIActivityIndicatorView!
var url = "http://******.be/agenda.php"
func loadURL () {
let requestURL = NSURL(string: url)
let request = NSURLRequest(URL: requestURL!)
webAgenda.loadRequest(request)
}
override func viewDidLoad() {
super.viewDidLoad()
loadURL()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func webViewDidStartLoad(webView: UIWebView) {
activityagenda.hidden = false
activityagenda.startAnimating()
}
func webViewDidFinishLoad(webView: UIWebView) {
activityagenda.hidden = true
activityagenda.stopAnimating()
}
because you load a http site so in iOS9 will have problem with App Transport Security.
disable ATS here
I am hoping someone maybe able to help, I am new too Xcode and have been trying relentlessly to execute the following URL in webview and not having much luck:
http://view.vzaar.com/5532785/player
Below is the code:
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL (string: "http://view.vzaar.com/5532785/player")
let requestObj = NSURLRequest(URL: url!);
webView.loadRequest(requestObj)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Any suggestions would be really appreciated.
Jon
Try this,
If you using Xcode 7(swift 2). Add following details in your plist
some disapointement with uiwebview, for very simple code
class ViewController: UIViewController {
#IBOutlet weak var mavue: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let requestURL = NSURL(string: "http://www.google.com")
let request = NSURLRequest(URL: requestURL!)
mavue?.loadRequest(request)
println("myWebView : \(mavue)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
println("myWebView : (mavue)") return nil
i try it on simulator, i have loaded my controllerview from presentViewController maybe it's the reason why?
but my code doesn't show mywebview.
mywebView is connected to my IBoutlet
thank
EDIT : It 's work, I think that th mistake was to keep the default uiviewcontroller , when i use a subclass all is ok
Thank