Jest błąd w Swift podkładki na wygodę inicjatora UIAlertView, trzeba użyć równinie initializer
let alert = UIAlertView()
alert.title = "Hey"
alert.message = "This is one Alert"
alert.addButtonWithTitle("Working!!")
alert.show()
Ten kod stylu jest bardziej zgodny z językiem Swift. Inicjator wygody wydaje mi się bardziej Celowy. Tylko moja opinia.
Uwaga: UIAlertView jest przestarzałe (patrz deklaracja), ale Swift obsługuje iOS7 i nie można używać UIAlertController na iOS 7
Widok Deklaracji UIAlertView w Xcode
// UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead
class UIAlertView : UIView {
Alert w Swift iOS 8 Tylko
var alert = UIAlertController(title: "Hey", message: "This is one Alert", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Working!!", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
Wygląda mi na błąd. – Adam
znajduję odpowiedź na http://stackoverflow.com/questions/24084521/uialertview-is-not-working-in-swift – rickdecard