How to display temporary popup message on iPhone/iPad/iOS

后端 未结 10 1008
孤城傲影
孤城傲影 2020-12-04 11:31

I\'d like to display a temporary message on the iPhone/iPad displaying confirmation of an action, or some quick status about some background activity.

Is there a st

10条回答
  •  醉话见心
    2020-12-04 11:58

    *Swift 2.2 Answer:

    func showPopupWithTitle(title: String, message: String, interval: NSTimeInterval) {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
        presentViewController(alertController, animated: true, completion: nil)
        self.performSelector(#selector(dismissAlertViewController), withObject: alertController, afterDelay: interval)
    }
    
    func dismissAlertViewController(alertController: UIAlertController) {
        alertController.dismissViewControllerAnimated(true, completion: nil)
    }
    
    showPopupWithTitle("Title", message: "Message", interval: 0.5)
    

提交回复
热议问题