How to add an action to a UIAlertView button using Swift iOS

后端 未结 8 1755
说谎
说谎 2020-12-12 22:13

I want to add another button other than the \"OK\" button which should just dismiss the alert. I want the other button to call a certain function.

var logInE         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-12 23:04

    based on swift:

    let alertCtr = UIAlertController(title:"Title", message:"Message", preferredStyle: .Alert)
    let Cancel = AlertAction(title:"remove", style: .Default, handler: {(UIAlertAction) -> Void in })
    let Remove = UIAlertAction(title:"remove", style: .Destructive, handler:{(UIAlertAction)-> Void 
        inself.colorLabel.hidden = true    
    })
    alertCtr.addAction(Cancel)
    alertCtr.addAction(Remove)
    
    self.presentViewController(alertCtr, animated:true, completion:nil)}
    

提交回复
热议问题