我的应用程序包含 Webview To Show Payment Form,当我们完成填写数据后,我们可以按下 Done 按钮,然后 Webview 将重定向到其他 Url。我已经搜索过这个函数,我找到了 shouldStartLoadWith 函数来解决这个问题,但是当我实现这个时,它不起作用
这是我的代码:
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if request.url?.absoluteString == "https://xyzbank.com" {
print("SUCCESS")
return false
}
print("NOT SUCCESS")
return true
}
Run Code Online (Sandbox Code Playgroud)
它不是打印它们中的任何一个。
这是我的其余代码:我认为我已经调用了 webview 的委托方法,但它仍然无法正常工作
override func viewDidLoad() {
super.viewDidLoad()
hud.textLabel.text = "Processing..."
hud.show(in: self.view)
let mpayment: Payment = params.payment
mywebview.navigationDelegate = self
//Showing webview url....
}
func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) {
print(error.localizedDescription)
}
func …Run Code Online (Sandbox Code Playgroud) 我想清除HTML String文本中的所有属性.我已经找到了很多答案,但问题是如果我们没有正确的CSS风格,正则表达式的语法不起作用.我的情况很困难,因为从API获取的HTML文本与其样式不一致.它可能是这样的:
<p style="\"text-align:" justify;="" \"=""><span style="\"font-size:" 13px;="" font-family:="" arial;="" text-decoration-skip-ink:="" none;\"=""><b><span style="font-size: 18px;">Angkor Wat</span></b> is a temple complex in Cambodia and the largest religious monument in the world, on a site measuring 162.6 hectares (1,626,000 m2; 402 acres). It was originally constructed as a Hindu temple dedicated to the god Vishnu for the Khmer Empire, gradually transforming into a Buddhist temple towards the end of the 12th century. It was built by the Khmer King Suryavarman II in the …Run Code Online (Sandbox Code Playgroud) 我已经在Github上的MaterialComponents上打开了这个问题,但似乎还没有答案.问题是,当我单击文本字段以激活然后我在外面单击时,它工作正常但是当我重复这样做时,文本字段的占位符将始终位于顶部
这是图像的问题
这是代码:
@IBOutlet weak var textfieldFloating: MDCTextField!
let tf = MDCTextInputControllerOutlined()
override func viewDidLoad() {
super.viewDidLoad()
textfieldFloating.leftView = UIImageView(image: UIImage(named: "ic_lock_outline_white_18pt"))
textfieldFloating.leftViewMode = .always
textfieldFloating.placeholder = "Placeholder"
tf.textInput = textfieldFloating
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
Run Code Online (Sandbox Code Playgroud)