UIKit 框架之UIAlertController
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相关推荐
- UIKit框架使用总结--看看你掌握了多少
一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...
- UIKit框架各个类的简介
1.UIAcceleration: 被叫做加速事件的一个UIAcceleration类的实例是用来代表即时的三维加速数据.为了接收重力加速度,要注册一个应用应用程序作为一个共享UIAccelerate ...
- iOS UIKit框架注解
本文来自简书,原文地址:http://www.jianshu.com/p/e5b995ecf44d 导语 我们追求技术的提升,关注技术的发展历程:作为从事技术工作的伐码猿,有个想法(仅是个人想法),这 ...
- UIKit 框架讲解
下面是UIKit 子类的具体说明 1.UIAcceleration: 被叫做加速事件的一个UIAcceleration类的实例是用来代表即时的三维加速数据.为了接收重力加速度,要注册一个应用应用程序作 ...
- IOS开发学习---Fundation框架和UIKit框架
框架是一个目录,包含了共享资源库,用于访问该资源库中储存的代码的头文件,以及图像.声音文件等其他资源.共享资源库定义应用程序可以调用的函数和方法. iOS 提供了许多可在应用程序开发中使用的框架.要使 ...
- uikit框架开发前期配置及定制主题方法。
要使用npm命令需要先安装nodejs. 安装方法网上有很多,在此就不一一例举了. 1. 安装Gulp > npm install -g gulp 首先需要在全局范围安装gulp 用git下载U ...
- UIKit框架类层次图
学习UIKit应该首选了解UIKit类的层次图,从根类一层一层的拨.
- #Objective - C - UI-design - 第六天 -UIKit框架-UIScrollView-分屏相册练习(相册缩略图变为浏览到第几张)
UIScrollView UIScrollView是所有滚动视图的基类 创建UIScrollView #define WIDTH self.view.frame.size.width#define H ...
- iOS基础-UIKit框架-高级视图-UIDatePicker
用处:用在自定义键盘(点击文本框时弹出日期选择.) 一.自定义键盘 先连接TextField -(viewDidLoad){[super viewDidLoad]; //1.创建时间选择器 UIDat ...
最新文章
- php中的关联数组,PHP中的多种关联数组
- 如何恢复电脑系统桌面
- P104-105代码中变量之间的关系
- 如何捕获 EF 生成的 SQL 脚本?
- 【BCVP更新】StackExchange.Redis 的异步开发方式
- 工作324:uni-时间过滤器封装
- 信息传递(NOIP2015提高组Day1T2)
- axure如何页面滑动时广告位上移_Axure8.0教程:模拟滑动效果
- DeepStream运行范例出错,提示缺少libnvinfer.so怎么办?
- 淘宝类目运营方法 怎么快速获取流量和销量
- 操作系统课程设计(页面置换算法 C语言)
- 【GPS】 根据GPS坐标求取两点间距离算法
- STM32单片机远程升级
- notepad++之正则表达式的使用
- 【芯片前端】Filelist -f/-F的文件解析方式探究
- sort()sorted()
- 武汉财政容灾系统应用案例
- String中与获取相关的几个方法
- 解决Vue中重复点击相同路由控制台报错问题
- 1.2 随机事件及其概率