Tôi nhận được lệnh: Không tìm thấy ký hiệu: _OBJC_CLASS _ $ _ UIAlertAction khi tôi cố gắng để có được tính quái dị này để chạy.Cảnh báo có thể hoạt động trên iOS 7 và iOS 8
Làm cách nào để liên kết yếu với 8.0 công cụ?
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;
Đã giải quyết: UIKit phải được đánh dấu Tùy chọn thay vì Bắt buộc. phiên bản đơn giản bây giờ là:
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)
}
thể trùng lặp của [Lỗi cho thấy một UIAlertView trong nhanh chóng] (http://stackoverflow.com/questions/24040519/error-showing-a-uialertview-in-swift) – Daniel
Đây là một superset của vấn đề bạn đã gọi. Người khác đã gợi ý let cảnh báo = UIAlertView() alert.title = "noop" alert.message = "Không có gì để xác minh" alert.addButtonWithTitle ("Click") alert.show() mà làm việc cho tôi. ai đó chắc chắn sẽ tìm thấy một lỗi với Apple về inti thuận tiện bị hỏng trên UIAlertView shim –
Vui lòng xem câu trả lời tôi đã xuất bản tại đây: [http://stackoverflow.com/a/24091779/1485344][1] [1]: http://stackoverflow.com/a/24091779/1485344 –