首页 > 编程语言 > 详细

【Swift】UIAlertController使用

时间:2015-04-26 10:42:15      阅读:621      评论:0      收藏:0      [点我收藏+]

func clickButton1(){

创建uialertcontroller

        var alertCtl : UIAlertController = UIAlertController(title: "Alert", message: "You clicked button1", preferredStyle: UIAlertControllerStyle.Alert)

添加action到uialertcontroller,action是UIalertcontroller上的按钮操作,建议至少添加一个,如果不添加,alertcontroller就没有相应的按钮退出

        var alertAction : UIAlertAction = UIAlertAction(title: "Action", style: UIAlertActionStyle.Default, handler: { (param : UIAlertAction!) -> Void in

            println("I am alert action")

            var position = self.view.center.x

        })

        alertCtl.addAction(alertAction)

显示alert controller

        self.presentViewController(alertCtl, animated: true, completion: nil)

        

        /*var alertView : UIAlertView = UIAlertView(frame: CGRect(origin: CGPoint(x: 50, y: 200), size: CGSize(width: 100, height: 40)))

        alertView.title = "Button1"

        alertView.message = "You clicked button1!"

        alertView.addButtonWithTitle("Confirm")

        alertView.delegate = self

        alertView.show()*/

    }

【Swift】UIAlertController使用

原文:http://www.cnblogs.com/AlwinXu/p/4457377.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!