Sto ricevendo dyld: Simbolo non trovato: _OBJC_CLASS _ $ _ UIAlertAction quando sto cercando di far funzionare questa mostruosità.Avviso che può funzionare su iOS 7 e iOS 8
Come faccio a fare un weaklink 8.0?
var device : UIDevice = UIDevice.currentDevice()!;
var systemVersion = device.systemVersion;
var iosVerion : Float = systemVersion.bridgeToObjectiveC().floatValue;
if(iosVerion < 8.0) {
let alert = UIAlertView()
alert.title = "Noop"
alert.message = "Nothing to verify"
alert.addButtonWithTitle("Click")
alert.show()
} else {
var alert : UIAlertController? = UIAlertController(title: "Noop", message: "Nothing to verify", preferredStyle: UIAlertControllerStyle.Alert)
if alert {
let actionStyle : UIAlertActionStyle? = UIAlertActionStyle.Default;
var alertAction : UIAlertAction? = UIAlertAction(title: "Click", style: actionStyle!, handler: nil)
if(alertAction) {
alert!.addAction(alertAction)
self.presentViewController(alert, animated: true, completion: nil)
}
}
}
return;
Risolto: UIKit ha dovuto essere contrassegnato Opzionale anziché Richiesto. Versione semplificata è ora:
var device : UIDevice = UIDevice.currentDevice()!;
var systemVersion = device.systemVersion;
var iosVerion : Float = systemVersion.bridgeToObjectiveC().floatValue;
if(iosVerion < 8.0) {
let alert = UIAlertView()
alert.title = "Noop"
alert.message = "Nothing to verify"
alert.addButtonWithTitle("Click")
alert.show()
} else {
var alert : UIAlertController = UIAlertController(title: "Noop", message: "Nothing to verify", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Click", style:.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
possibile duplicato di [Error mostrando un'UIAlertView in rapida] (http://stackoverflow.com/questions/24040519/error-showing-a-uialertview-in-swift) – Daniel
Questo è un superset del problema ti sei riferito. Qualcun altro ha suggerito let avviso = UIAlertView() alert.title = "Noop" alert.message = "Niente da verificare" alert.addButtonWithTitle ("click") alert.show() che ha lavorato per me. qualcuno dovrebbe sicuramente trovare un bug con la convenienza inti rotto sullo shim UIAlertView –
Si prega di dare un'occhiata alla risposta che ho pubblicato qui: [http://stackoverflow.com/a/24091779/1485344][1] [1]: http://stackoverflow.com/a/24091779/1485344 –