alertView的使用
let alertView = UIAlertView()
alertView.delegate = self
alertView.alertViewStyle = UIAlertViewStyle(rawValue: 2)!;
alertView.title = "标题"
alertView.message = "这个是UIAlertView的默认样式"
alertView.addButton(withTitle: "取消")
alertView.addButton(withTitle: "好的")
alertView.show()
后来发现 这个方法还是很方便的
let alertController = UIAlertController(title: "添加相册",
message: "请输入相册名称", preferredStyle: .alert)
alertController.addTextField {
(textField: UITextField!) -> Void in
textField.placeholder = "相册名称"
}
let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)
let okAction = UIAlertAction(title: "好的", style: .default, handler: {
action in
//也可以用下标的形式获取textField let login = alertController.textFields![0]
let name = alertController.textFields!.first!
print("用户名:\(name.text)")
})
alertController.addAction(cancelAction)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
swift 页面跳转
let ptotoView = PhotoController()
//跳转
self.navigationController?.pushViewController(ptotoView , animated: true)
网友评论