码迷,mamicode.com
首页 > 编程语言 > 详细

swift 中 如何给 Alert 增加 target 事件

时间:2014-10-09 15:08:23      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   使用   ar   sp   div   

swift 中 如何给 Alert 增加 target 事件   

使用UIAlertView时,
let  UpdateAler = UIAlertView()
            UpdateAler.addButtonWithTitle("更新") //Prints 0
            UpdateAler.addButtonWithTitle("忽略") //Prints 1
            UpdateAler.title = "提示";
            UpdateAler.message = "请确认是否输入8或10位数字证书号";
            UpdateAler.show()
            UpdateAler.delegate = self   //不要忘记
func alertView(View: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){
        
        switch buttonIndex{
            
        case 0:
            NSLog("开始更新");
            UIApplication.sharedApplication().openURL(NSURL(string : "tel://9809088798"))
        case 1:
            NSLog("忽略");
        default:
            break
            //Some code here..
            
        }
    }

还有一种情况是使用:

UIAlertController

 

 

swift 中 如何给 Alert 增加 target 事件

标签:style   blog   http   color   io   使用   ar   sp   div   

原文地址:http://www.cnblogs.com/ericjun/p/4012722.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!