当我尝试运行这个庞然大物时,出现了dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction。
我该如何弱化链接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;
已解决:必须将UIKit标记为可选项而不是必需项。现在的简化版本是:
已解决:必须将UIKit标记为可选项而不是必需项。现在的简化版本是:
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)
}
let alert = UIAlertView() alert.title = "Noop" alert.message = "Nothing to verify" alert.addButtonWithTitle("Click") alert.show()
这对我有效。有人应该向苹果报告一个关于UIAlertView shim中方便初始化损坏的错误。 - Anton Tropashko