测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布日期最后发布日期 | 2017年3月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✓ |
由 Lucas Farah 维护。
带有初始化处理程序的 UIAlertController Swift 扩展
为什么?因为 UIAlertController 在每个操作中都有处理程序,迫使开发者要有 重复代码。相反,我们可以在任何操作被调用时,在全局处理程序内有一个 switch,该处理程序会调用
将 LFAlertController.swift 从 /Sources 拖动到您的项目中
.Package(url: "https://github.com/awesome-labs/LFAlertController.git", majorVersion: 0)
let action1 = UIAlertAction(title: "Second Action", style: .Default)
带有处理程序的 UIAlertController
self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert,actions:[action0,action1])
{ (action,index) -> () in
//Printing index of Action
print("\(index) - \(action.title!)")
}
self.controller.show()
带有处理程序的 UIAlertAction
let action0 = UIAlertAction(title: "First Action", style: .Default, handler: nil)
不带处理程序的 UIAlertController
self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert, actions: [action0,action1])