swift UIWebView Into Alert -


i want open alert within uiwebview programmatically. created message, action , setted own size uialert.

the following code:

var title = "pp"     var message = "\n\n\n\n\n\n\n\n\n\n\n\n";     var alert = uialertcontroller(title: title, message: message, preferredstyle: uialertcontrollerstyle.alert);     var cancel = uialertaction(title: "chiudi", style: uialertactionstyle.destructive, handler: nil)     var height:nslayoutconstraint = nslayoutconstraint(item: alert.view, attribute: nslayoutattribute.height, relatedby: nslayoutrelation.equal, toitem: nil, attribute: nslayoutattribute.notanattribute, multiplier: 1, constant: self.view.frame.height * 0.90)     alert.view.addconstraint(height);     alert.view.frame.size.height = self.view.frame.height * 0.90      var web = uiwebview(frame: cgrect(x: 15, y: 60, width: self.view.frame.size.width * 0.8 - 15, height: self.view.frame.size.height * 0.8 - 95))      let requesturl = nsurl(string: "http://www.google.it")     let request = nsurlrequest(url: requesturl!)     web.scalespagetofit = true     web.loadrequest(request)     alert.view.addsubview(web)     alert.addaction(cancel)     self.presentviewcontroller(alert, animated: true, completion: nil) 

ok, result enter image description here

i dont button's position on webview, should below view.

thanks @ in advance.

you should add set of \n\n\n\n\n\n\n\n\n\n\n\n var message = "\n\n\n\n\n\n\n\n\n\n\n\n"; becomes var message = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n”;. uiwebview doesn’t seem it’s affecting height of uialertcontroller, looks message is. should fix problem, although should consider changing vars let.

here full code should like: let title = "privacy policy" let message = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

let alert = uialertcontroller(title: title, message: message, preferredstyle: uialertcontrollerstyle.alert) let cancel = uialertaction(title: "chiudi", 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: self.view.frame.height * 0.90) alert.view.addconstraint(height); alert.view.frame.size.height = self.view.frame.height * 0.90  let web = uiwebview(frame: cgrect(x: 15, y: 50, width: self.view.frame.size.width * 0.8 - 15, height: self.view.frame.size.height * 0.85 - 95)) // take note right here, in height:, i’ve changed 0.8 0.85 should more consistent on top , bottom let requesturl = nsurl(string: "http://www.google.it"); let request = nsurlrequest(url: requesturl!); web.loadrequest(request);  web.scalespagetofit = true web.loadrequest(request) alert.view.addsubview(web) alert.addaction(cancel) self.presentviewcontroller(alert, animated: true, completion: nil) 

that should needs :)


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -