学习遇到的问题----ios9中 UIAlertController相关

来源:互联网 发布:怎么制作数据分析表 编辑:程序博客网 时间:2024/05/16 13:53

1. 如果要添加 TextField 到 Alert 中,

需要先配置

let alert = UIAlertController(title: "New Name", message: "Add a new name", preferredStyle: .Alert)                alert.addTextFieldWithConfigurationHandler { (textfield: UITextField) -> Void in            textfield.placeholder = "Name"        }                let saveAction = UIAlertAction(title: "Save", style: .Default) { (action) -> Void in            let textField = alert.textFields!.first            self.names.append(textField!.text!)            self.tableView.reloadData()        }

否则无法显示

0 0
原创粉丝点击