Swift自學(xué)記錄

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)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容