我正在开发一款应用,但我无法使用此功能! webView应加载facebook.com/profile.php或类似的东西,当url等于facebook.com/profile.php时,应加载警报。我现在拥有的代码即使没有登录也会发出警报。所以代码应检查用户是否在个人资料页面上,当用户登录facebook时,应该在profile.php时加载警报到达了。我无法理解这样做。我想我应该在webview完成加载时检查当前网址但是我无法让它工作..这是我的代码:
webView.delegate = self
let url = NSURL(string: "https://m.facebook.com/profile.php?ref=bookmarks")!
webView.loadRequest(NSURLRequest(URL: url))
self.displayAlert("Download Complete", message: "Your Facebook Profile Viewers were succesfully found!")
func webViewDidFinishLoad(webview: UIWebView) {
print("it worked")
if let currentURL = webView.request?.URL!.absoluteString {
print(currentURL)
} else {
}
}
task.resume()
任何帮助表示赞赏! 谢谢!