ios学习之alertView的基本使用
2015-10-18 16:48
519 查看
在最新的ios9中 使用AlertController来使用的 所以 如果要呈现的话 就只要self.presentViewController即可
alertview是一个警告框提示的作用,
需要用到的知识有
![](http://img.blog.csdn.net/20151018164916265?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
以下是具体的代码
http://www.hcxy.me/course/19/learn#lesson/237
具体看这个
alertview是一个警告框提示的作用,
需要用到的知识有
以下是具体的代码
class ViewController: UIViewController { //声明一个UIAlertController实例,以便在下方代码中进行调用 var controller: UIAlertController? override func viewDidLoad() { //创建一个alertcontroller的实例 最上面的标题,还有信息,以什么方式弹出这个警告框 controller = UIAlertController(title: "曹凯强", message: "爱我请点我", preferredStyle: UIAlertControllerStyle.Alert) //创建在点击的时候该发生什么函数 action let action = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default,handler: {(paramAction:UIAlertAction!) -> Void in print("nihao") }) super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } //创建一个文本输入框 let action1 = UIAlertAction(title: "nihao", style: UIAlertActionStyle.Default) { (paramAction:UIAlertAction!) -> Void in if let textField = self.controller.textFields{ let textFields = textField as [UITextField] } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } //应该是在主视图加载完成之后再去显示这个视图,所以要重写这个函数 //viewDidAppear override func viewDidAppear(animated: Bool) { super.viewDidAppear(true) //呈现这个controller的时候所用的方法 self.presentViewController(controller!, animated: true, completion: nil) } }
http://www.hcxy.me/course/19/learn#lesson/237
具体看这个
相关文章推荐
- iOS中通知中心NSNotificationCenter的应用
- ios NSURLSession使用说明及后台工作流程分析
- iOS 新浪微博-4.0 OAuth授权
- ios开机启动引导页
- 【黑马训练营】IOS C语言代码块
- iOS开发控件基础
- 三种方式使得iOS应用能够在后台进行数据更新和下载
- iOS开发之理解iOS中的MVC设计模式
- iOS如何兼容的应用程序32位系统和64Bit系统
- [iOS]关于计算文字所占范围大小的方法
- iOS Core Animation学习总结(3)--动画的基本类型
- IOS二维码的应用
- 如何在 iOS 9 中创建 Stack View
- iOS开发- 隐藏键盘总结
- iOS常见控件设置
- 简单动画
- 用CocoaPods做iOS程序的依赖管理(转摘)
- iOS开发——友盟分享
- iOS应用中的素材讲解
- 遍历数组的两种方法