Error showing a UIAlertView in swift

前端 未结 7 2036
独厮守ぢ
独厮守ぢ 2021-02-20 06:11

Im trying to show a UIAlertView in my swift App

    alert = UIAlertView(title: \"\",
        message: \"bla\",
        delegate: self,
        cancelButtonTitle:         


        
7条回答
  •  独厮守ぢ
    2021-02-20 07:05

    var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
    self.presentViewController(alert, animated: true, completion: nil)
    

    To handle actions:

    alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { 
        action in switch action.style {
        case .Default:
            println("default")
        case .Cancel:
            println("cancel")
        case .Destructive:
            println("destructive")
        }
    }))
    

提交回复
热议问题