I know problems like this have been posted here, but I looked through the previous threads and wasn't able to find an answer. I am trying to use stringByEvaluatingJavaScriptFromString in swift, and it is not working. Please help! Code:
import UIKit
import Foundation
import iAd
class zmanimViewController: UIViewController, ADBannerViewDelegate, UIWebViewDelegate {
//variables*******************************************
var adBannerView = ADBannerView(adType: ADAdType.Banner)
@IBOutlet weak var webView: UIWebView!
//functions*******************************************
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.canDisplayBannerAds = true
webView.delegate = self
var url = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("testHTML", ofType: "html")!)
loadLocalHtmlFile(webView, url!)
//var jsZoom25 = "alert(\"ran\");"
//changeWebViewFontSize(2, webView)
}
func webViewDidFinishLoad(webView: UIWebView) {
//changeWebViewFontSize(2, webView)
var jsZoom25 = "alert(\"ran1\"); document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust=450%; alert(\"ran2\");"
webView.stringByEvaluatingJavaScriptFromString(jsZoom25)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Thanks in advance! Additional info: If I make the javascript only "alert('ran');", it shows the alert, but it does't show the alerts in the javascript that I need to work.