Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift:基于网页元素位置的位置控制_Ios_Swift_Webview - Fatal编程技术网

Ios Swift:基于网页元素位置的位置控制

Ios Swift:基于网页元素位置的位置控制,ios,swift,webview,Ios,Swift,Webview,我需要根据网页中的一个元素,在UIWebView上放置一个ui按钮。 我使用stringByEvaluatingJavaScript实现了这一点 let webSettingsButtonTopString : String = "document.getElementById('settingsBtn').offsetTop;" settingsButtonTop = Int(self.wvWinfoDashboard.stringByEvaluatingJavaScript(from: we

我需要根据网页中的一个元素,在
UIWebView
上放置一个
ui按钮。
我使用
stringByEvaluatingJavaScript
实现了这一点

let webSettingsButtonTopString : String = "document.getElementById('settingsBtn').offsetTop;"
settingsButtonTop = Int(self.wvWinfoDashboard.stringByEvaluatingJavaScript(from: webSettingsButtonTopString)!)
lcSettingsButtonTopAlign.constant = CGFloat(settingsButtonTop)
问题在于,此解决方案取决于
设置按钮的设置值。如果页面无法加载或加载时间过长,则不会发生任何事情

我能想到的另一个解决方案是根据显示分辨率管理
ui按钮的位置,但我不喜欢这个想法,因为它不是动态的


关于如何解决这个问题,您有什么建议吗?

您应该使用WKwebview@IOSSingh-谢谢你的建议。不幸的是,现在有点太晚了,因为整个应用程序都是基于网络视图的,切换需要一些时间。