通过使用Firebase数据库我试图用RealTime更新这个旧的代码的URL字符串,因为URL有时会变坏,我必须尽快更新它。我尝试了一些理论,其中没有一个正在被正确处理。除了下面的代码..如果链接被破坏的ID没有实时访问来更新它..我需要帮助做一个代码,它会更新它实时。Swift 3 Firebase数据库抓取URLString
<a target="_blank" href="https://imageshack.com/i/plyd7Ztkp"><img src="http://imagizer.imageshack.us/v2/640x480q90/921/yd7Ztk.png" border="0"></a>
<a target="_blank" href="https://imageshack.com/i/plMFPoMRp"><img src="http://imagizer.imageshack.us/v2/640x480q90/921/MFPoMR.png" border="0"></a>
从上面的图片,如果我是从 “www.google.com” 更改为任何其他网址也应该更新web视图。
我希望我足够的什么,我试图完成
@IBAction func zhwandoontv(_ sender: Any) {
webView.frame=self.view.bounds;
webView.allowsInlineMediaPlayback = true;
webView.mediaPlaybackRequiresUserAction = false;
let tolourl = URL(string: "http://38.99.146.180:7777/Zhwandoon.m3u8?user=sgls128196012&session=a9a822ced3f0211c85d67487a252d6497bef40a6bd64e0f01c332de5c9369")
let toloURLRequest = URLRequest(url: tolourl!)
webView.loadRequest(toloURLRequest)
}
更新明确:
}
@IBOutlet weak var webView: UIWebView!
var ref:FIRDatabaseReference?
var databaseHandle:FIRDatabaseHandle?
var postData = [String]()
@IBAction func Bahartv(_ sender: Any) {
ref = FIRDatabase.database().reference()
databaseHandle = ref?.child("realtimeURL").observe(.childAdded, with: { (snapshot) in
let post = snapshot.value as? String
if let actualPost = post {
self.postData.append(actualPost)
}
})
webView.frame=self.view.bounds;
webView.allowsInlineMediaPlayback = true;
webView.mediaPlaybackRequiresUserAction = false;
let tolourl = self.postData.append(actualPost)
let toloURLRequest = URLRequest(url: tolourl!)
webView.loadRequest(tolourl)
}
override func viewDidLoad() {
super.viewDidLoad()
ref = FIRDatabase.database().reference()
databaseHandle = ref?.child("realtimeURL").observe(.childAdded, with: { (snapshot) in
let post = snapshot.value as? String
if let actualPost = post {
self.postData.append(actualPost)
}
})
// Do any additional setup after loading the view.
}
有人吗?谢谢对不起... – Sadin