i want to open an alert within an UIWebView programmatically. So i created a message, an action and i setted my own size to UIAlert.
The following is my 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, my result is something like this

I dont really like that button's position over the WebView, it should be below the view.
Thanks at all in advance.
You should just add another set of
\n\n\n\n\n\n\n\n\n\n\n\ntovar message = "\n\n\n\n\n\n\n\n\n\n\n\n";so it becomesvar 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”;. The UIWebView doesn’t seem like it’s affecting the height of the UIAlertController, it looks like the message is. This should fix the problem, although you should consider changing all thevars tolet.Here is what the full code should look 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";
That should be all it needs :)