在swift中是否有代码用于停用/激活WebView上按钮的触摸点击?
答案 0 :(得分:2)
如果您想要这样做,可以激活/停用userInteraction:
SELECT * FROM customer
WHERE id IN (
SELECT DISTINCT L1.customer_id AS id
FROM payment_log L1
LEFT JOIN payment_log L2 ON L1.customer_id = L2.customer_id
WHERE
L1.payment_date < '2016-03-22'
AND L2.payment_date > '2016-03-22' AND L2.payment_type_id = 3
)
答案 1 :(得分:1)
只需激活/停用您的按钮即可使用委托方法:
webViewDidFinishLoad(_ webView: UIWebView)
func webViewDidFinishLoad(webView: UIWebView) {
let js = "document.getElementById('yourButton').disabled = true;);"
self.webView.stringByEvaluatingJavaScriptFromString(js)
}
但是,如果你想与触摸互动添加一些假设你的HTML代码:
<a class="yourButton" href="inapp://capture">Button Text</a>
使用UIWebView委托方法:
webView(_:shouldStartLoadWithRequest:navigationType:) 你可以这样做:
func webView(WebViewNews: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool {
if request.URL.scheme == "inapp" {
if request.URL.host == "capture" {
// do capture action and do whatever you want
}
return false
}
return true
}
答案 2 :(得分:0)
1)如果要激活/停用html按钮,则必须使用方法
>:t transform :: (Transformable a a', Transformable b b') => Either a b -> Either a' b'
<interactive>:1:1: Warning:
Overlapping instances for Transformable
(Either a1 b1) (Either a'1 b'1)
arising from a use of `transform'
Matching instances:
instance [overlappable] (Transformable l l', Transformable r r') =>
Transformable (Either l r) (Either l' r')
-- Defined at test6.hs:9:31
instance [overlap ok] Transformable a a -- Defined at test6.hs:6:27
(The choice depends on the instantiation of `a1, b1, a'1, b'1'
To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
In the expression:
transform ::
(Transformable a a', Transformable b b') =>
Either a b -> Either a' b'
示例强>
stringByEvaluatingJavaScriptFromString
通过此方法,您可以访问html按钮,并可以通过webview委托方法激活/取消激活。
2)如果您的按钮是原生按钮,那么您可以这样做 userInteractionEnabled属性
示例
func webView(WebViewNews: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool
{
let result = webView.stringByEvaluatingJavaScriptFromString("document.getElementById('btnname').disabled = true;")
}
答案 3 :(得分:0)
您可以执行javascript以从webview中禁用该按钮 - stringByEvaluatingJavaScriptFromString:
self.webView.stringByEvaluatingJavaScriptFromString("document.getElementById('myBtn').disabled = true;")