Swift 简单控件示例:d框(UIAlertController)

Swift 简单控件示例:d框(UIAlertController),第1张

概述转载请声明出处:http://blog.csdn.net/jinnchang/article/details/44593215 ------------------------------------------------------------------------------------------ //// ViewController.swift// UIAlertContro 转载请声明出处:http://www.jb51.cc/article/p-ynkdlzzu-ga.html
------------------------------------------------------------------------------------------

////  VIEwController.swift//  UIAlertControllerSample////  Created by jinnchang on 15/4/2.//  copyright (c) 2015年 Jinn Chang. All rights reserved.//import UIKitclass VIEwController: UIVIEwController {        var alert: UIAlertController!    var actionSheet: UIAlertController!    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        // Do any additional setup after loading the vIEw,typically from a nib.                let button1 = UIbutton.buttonWithType(.System) as UIbutton        button1.frame = CGRectMake(30,50,self.vIEw.frame.wIDth - 60,100)        button1.setTitle("Alert",forState: .normal)        button1.addTarget(self,action: "buttonAction:",forControlEvents: .touchUpInsIDe)        button1.tag = 1                let button2 = UIbutton.buttonWithType(.System) as UIbutton        button2.frame = CGRectMake(30,150,100)        button2.setTitle("Action Sheet",forState: .normal)        button2.addTarget(self,forControlEvents: .touchUpInsIDe)        button2.tag = 2                // 定义菜单按钮        let cancelAction = UIAlertAction(Title: "Cancel",style: .Cancel,handler: nil)        let okAction = UIAlertAction(Title: "Ok",style: .Default) {            (action: UIAlertAction!) -> VoID in            println("you choose ok")        }        let deleteAction = UIAlertAction(Title: "Delete",style: .Destructive) {            (action: UIAlertAction!) -> VoID in            println("you choose delete")        }                // 定义一个 Alert        alert = UIAlertController(Title: "simple alert",message: "this is a simple alert",preferredStyle: .Alert)        alert.addAction(cancelAction)        alert.addAction(okAction)        alert.addAction(deleteAction)                // 定义一个 ActionSheet        actionSheet = UIAlertController(Title: "simple action sheet",message: "this is a simple action sheet",preferredStyle: .ActionSheet)        actionSheet.addAction(cancelAction)        actionSheet.addAction(okAction)        actionSheet.addAction(deleteAction)                self.vIEw.addSubvIEw(button1)        self.vIEw.addSubvIEw(button2)    }    overrIDe func dIDReceiveMemoryWarning() {        super.dIDReceiveMemoryWarning()        // dispose of any resources that can be recreated.    }        /// 响应按钮点击事件    func buttonAction(sender: UIbutton) {        let num = sender.tag        switch num {        case 1:            self.presentVIEwController(alert,animated: true,completion: nil)        case 2:            self.presentVIEwController(actionSheet,completion: nil)        default:            break        }    }}
------------------------------------------------------------------------------------------
GitHub 上项目地址:UIAlertControllerSample
控件更多相关属性及方法参考:UIAlertController Class Reference 文章最后更新时间:2015年4月3日11:04:40
总结

以上是内存溢出为你收集整理的Swift 简单控件示例:d框(UIAlertController)全部内容,希望文章能够帮你解决Swift 简单控件示例:d框(UIAlertController)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1088501.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存