IOS8之后增加了UIAlertController类,它可以表示UIAlertView和UIActionSheet.它继承自UIViewController。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window.backgroundColor=[UIColor whiteColor];[self.window makeKeyAndVisible];ViewController *vc=[[ViewController alloc]init];UINavigationController *nvc=[[UINavigationController alloc]initWithRootViewController:vc];self.window.rootViewController=nvc;return YES;
}
//
//  ViewController.m
//  AlertVC
//
//  Created by City--Online on 15/5/25.
//  Copyright (c) 2015年 XQB. All rights reserved.
//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];btn.frame=CGRectMake(100, 100, 50, 50);[btn setTitle:@"按钮" forState:UIControlStateNormal];[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];btn.layer.borderWidth=2.0;[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];}
-(void)btnClick:(id)sender
{
//    UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
//
//    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//        textField.text=@"name";
//        textField.clearsOnBeginEditing=YES;
//    }];
//    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//        textField.text=@"password";
//        textField.clearsOnBeginEditing=YES;
//    }];UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction *actionOk=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {NSLog(@"确定");}];UIAlertAction *actionCancel=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {NSLog(@"取消");}];[alert addAction:actionOk];[alert addAction:actionCancel];[self presentViewController:alert animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}@end

UIKit 框架之UIAlertController相关推荐

  1. UIKit框架使用总结--看看你掌握了多少

    一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...

  2. UIKit框架各个类的简介

    1.UIAcceleration: 被叫做加速事件的一个UIAcceleration类的实例是用来代表即时的三维加速数据.为了接收重力加速度,要注册一个应用应用程序作为一个共享UIAccelerate ...

  3. iOS UIKit框架注解

    本文来自简书,原文地址:http://www.jianshu.com/p/e5b995ecf44d 导语 我们追求技术的提升,关注技术的发展历程:作为从事技术工作的伐码猿,有个想法(仅是个人想法),这 ...

  4. UIKit 框架讲解

    下面是UIKit 子类的具体说明 1.UIAcceleration: 被叫做加速事件的一个UIAcceleration类的实例是用来代表即时的三维加速数据.为了接收重力加速度,要注册一个应用应用程序作 ...

  5. IOS开发学习---Fundation框架和UIKit框架

    框架是一个目录,包含了共享资源库,用于访问该资源库中储存的代码的头文件,以及图像.声音文件等其他资源.共享资源库定义应用程序可以调用的函数和方法. iOS 提供了许多可在应用程序开发中使用的框架.要使 ...

  6. uikit框架开发前期配置及定制主题方法。

    要使用npm命令需要先安装nodejs. 安装方法网上有很多,在此就不一一例举了. 1. 安装Gulp > npm install -g gulp 首先需要在全局范围安装gulp 用git下载U ...

  7. UIKit框架类层次图

    学习UIKit应该首选了解UIKit类的层次图,从根类一层一层的拨.

  8. #Objective - C - UI-design - 第六天 -UIKit框架-UIScrollView-分屏相册练习(相册缩略图变为浏览到第几张)

    UIScrollView UIScrollView是所有滚动视图的基类 创建UIScrollView #define WIDTH self.view.frame.size.width#define H ...

  9. iOS基础-UIKit框架-高级视图-UIDatePicker

    用处:用在自定义键盘(点击文本框时弹出日期选择.) 一.自定义键盘 先连接TextField -(viewDidLoad){[super viewDidLoad]; //1.创建时间选择器 UIDat ...

最新文章

  1. php中的关联数组,PHP中的多种关联数组
  2. 如何恢复电脑系统桌面
  3. P104-105代码中变量之间的关系
  4. 如何捕获 EF 生成的 SQL 脚本?
  5. 【BCVP更新】StackExchange.Redis 的异步开发方式
  6. 工作324:uni-时间过滤器封装
  7. 信息传递(NOIP2015提高组Day1T2)
  8. axure如何页面滑动时广告位上移_Axure8.0教程:模拟滑动效果
  9. DeepStream运行范例出错,提示缺少libnvinfer.so怎么办?
  10. 淘宝类目运营方法 怎么快速获取流量和销量
  11. 操作系统课程设计(页面置换算法 C语言)
  12. 【GPS】 根据GPS坐标求取两点间距离算法
  13. STM32单片机远程升级
  14. notepad++之正则表达式的使用
  15. 【芯片前端】Filelist -f/-F的文件解析方式探究
  16. sort()sorted()
  17. 武汉财政容灾系统应用案例
  18. String中与获取相关的几个方法
  19. 解决Vue中重复点击相同路由控制台报错问题
  20. 1.2 随机事件及其概率

热门文章

  1. 算法:数组中的逆序对
  2. 学习dubbo遇到的问题1
  3. C# DataTable 和List之间相互转换的方法
  4. 【HDU 1150】Machine Schedule(二分图匹配)
  5. 真正解决ASP.NET每一个页面首次访问超级慢的问题
  6. 好记性不如烂笔头——.NET运行原理
  7. 关于android的零碎问题的整理
  8. Oracle技术之O7_DICTIONARY_ACCESSIBILITY(二)
  9. Jquery导航条淡进淡出相册(动态无刷新加载数据库数据)
  10. 交换机命令行配置与VLAN