Bild hinzufügen, um UIAlertController
Ich möchte ein Bild hinzufügen, um UIAlertController. Bild nicht brauchen, um auf eine Schaltfläche, nur stellte in der Mitte des Controllers. Der code, den ich habe, ist unten aber stürzt mit der Meldung "nicht erkannte selector geschickt Instanz".
func showAlert () {
let alert = UIAlertController(title: "Title of Alert",
message: "none",
preferredStyle:UIAlertControllerStyle.ActionSheet)
//add an image
let image = UIImage(named: "example")
var imageView = UIImageView(image: image)
imageView.frame = CGRectMake(0, 0, 100, 100)
var imageAction = UIAlertAction(title: "", style:.Default, handler: nil)
imageAction.setValue(imageView, forKey: "image")
alert.addAction(imageAction)
//add a continue button
var action = UIAlertAction(title: "Continue", style:.Default, handler: {(alert:UIAlertAction!) in self.continue() })
alert.addAction(action)
//show the UIAlertController
self.presentViewController(alert, animated: true, completion: nil)
}
Was ist die unrecognized selector?
InformationsquelleAutor richc | 2015-08-17
Du musst angemeldet sein, um einen Kommentar abzugeben.
Leider von Apple nicht erlauben es uns, um Bilder hinzuzufügen, zu
UIAlertController
oderUIAlertView
. Diese APIs sind beschränkt auf die Apple Human Interface Guidelines.Wenn Sie wirklich brauchen ein Bild in einem
UIAlertController
-wie dialog, ich würde empfehlen, versucht so etwas wie https://github.com/wimagguc/ios-custom-alertview.Es gibt einen Weg, es zu tun, obwohl stringcode.co.uk/alertviewcontroller
InformationsquelleAutor Willow Bumby