How can I press the alert ok button programmatically?

后端 未结 8 1209
有刺的猬
有刺的猬 2020-12-21 11:15

How can I press the OK button in a JS alert programmatically?

What I want to do: every time after the alert is created, the OK button is pressed.

This is for

8条回答
  •  醉话见心
    2020-12-21 11:31

    Swift 3

    you want to try this code in show alert and ok and cancel button

    let sharephotoAction = UIAlertController.init(title: "Confirm Ticket", message:"Please Collect Your Ticket Before 1 Hours Ago in Location", preferredStyle: .alert )
            sharephotoAction.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (alertAction) in
    
                _ = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.Save), userInfo: nil, repeats: false)
    
            }))
            sharephotoAction.addAction(UIAlertAction(title: "Cancle", style: .default, handler:nil))
    
            self.present(sharephotoAction, animated: true, completion:nil)
    

提交回复
热议问题