IOS AlertView中的ReCaptcha

时间:2018-09-17 10:12:53

标签: ios swift recaptcha

我想问一下如何在UIAlertView内制作ReCaptcha吗?

我使用ReCaptcha库。

let alert = UIAlertController(title: title, message: "Captcha", preferredStyle: UIAlertControllerStyle.alert)
let cancel = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.destructive, handler: nil)

let height:NSLayoutConstraint = NSLayoutConstraint(item: alert.view, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 400)
alert.view.addConstraint(height);
alert.view.frame.size.height = 400

let web = UIWebView(frame: CGRect(x: 5 , y: 50, width: 260, height: 300)) // take note that right here, in the height:, I’ve changed 0.8 to 0.85 so it should look more consistent on the top and bottom

web.scalesPageToFit = true
recaptcha?.forceVisibleChallenge = true
recaptcha = try! ReCaptcha(apiKey: "key",baseURL: URL(string: "http://localhost"), endpoint: ReCaptcha.Endpoint.default)
recaptcha?.rx.validate(on: web)
    .subscribe(onNext: { (token: String) in
        // Do something
    })

alert.view.addSubview(web)
alert.addAction(cancel)
self.present(alert, animated: true, completion: nil)

0 个答案:

没有答案