ios - 在Swift 3中弹出模态

标签 ios swift3 mobile-application

我想使用swift实现弹出模式。我必须实现这样,根据用户的响应(是/否)再弹出一个弹出窗口,如何实现呢?
任何帮助都会非常有帮助。

最佳答案

UIAlertController是为此目的而设计的。

        let alertController = UIAlertController(title: "Default AlertController", message: "A standard alert", preferredStyle: .Alert)

        let cancelAction = UIAlertAction(title: "No", style: .Cancel) { (action:UIAlertAction!) in
            println("you have pressed the No button");
            //Call another alert here
        }
        alertController.addAction(cancelAction)

        let OKAction = UIAlertAction(title: "Yes", style: .Default) { (action:UIAlertAction!) in
            println("you have pressed Yes button");
            //Call another alert here
        }
        alertController.addAction(OKAction)

        self.presentViewController(alertController, animated: true, completion:nil)

关于ios - 在Swift 3中弹出模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43370184/

相关文章:

iphone - 在核心图折线图中旋转数据标签

swift - AudioPlayer 和锁屏/控制中心控制 Swift

ios - swift 3 中的自定义复选框

java - 方向更改后按钮和菜单停止工作

operating-system - 如何为使用 KaiOS 的手机创建应用程序?

java - Appium - Android 重新获取和刷新网络状态

ios - 在 UITableView 中过滤 NSMutableDictionary 数据

javascript - 无法在 Safari 上的 IndexedDB 中存储 Blob 类型

ios - 播放 mp3/wav 声音导致异常

ios - 导入动态创建的 Swift 类