2
在尝试实现UI警报时,我遇到了一些问题。我正在使用Xcode 8 beta 4中的swift 3.0,我试图让一个按钮激活一个警报,一个按钮(取消)取消警报另一个(ok)执行一个动作作为UIAction按钮,但是我一直无法甚至得到一个警报显示。为什么不显示此UIAlertController?
var warning = UIAlertController(title: "warning", message: "This will erase all content", preferredStyle: .Alert)
var okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
}
var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
UIAlertAction in
NSLog("Cancel Pressed")
}
warning.addAction(okAction) {
// this is where the actions to erase the content in the strings
}
warning.addAction(cancelAction)
self.presentViewController(warning, animated: true, completion: nil)
非常感谢你,当我回家的时候给它一个尝试,但它对于swift3.0还没有太多帮助。大大appriecated。 – Yellow