alertView的使用
let alertView = UIAlertView()
alertView.delegate = self
alertView.alertViewStyle = UIAlertViewStyle(rawValue: 2)!;
alertView.title = "標(biāo)題"
alertView.message = "這個是UIAlertView的默認樣式"
alertView.addButton(withTitle: "取消")
alertView.addButton(withTitle: "好的")
alertView.show()
后來發(fā)現(xiàn) 這個方法還是很方便的
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
//也可以用下標(biāo)的形式獲取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 頁面跳轉(zhuǎn)
let ptotoView = PhotoController()
//跳轉(zhuǎn)
self.navigationController?.pushViewController(ptotoView , animated: true)