UIAlertAction 和UIAlertController (UIAlertViewUIActionSheet)
2015-09-22 08:03
567 查看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
// Override point for customization after application launch.
// self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
// self.window.backgroundColor=[UIColor whiteColor];
//创建两个按钮
// UIButton *but1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, 150, 30)];
// [but1 setTitle:@"警报" forState:UIControlStateNormal];
// but1.backgroundColor=[UIColor blackColor];
//
// [but1 addTarget:self action:@selector(actal:) forControlEvents:UIControlEventTouchUpInside];
// UIButton *but2 = [[UIButton alloc]initWithFrame:CGRectMake(170, 50, 150, 30)];
// [but2 setTitle:@"操作表" forState:UIControlStateNormal];
// but2.backgroundColor=[UIColor blackColor];
// [but2 addTarget:self action:@selector(actlist:) forControlEvents:UIControlEventTouchUpInside];
//
// [self.window addSubview:but1];
// [self.window addSubview:but2];
// [self.window makeKeyAndVisible];
return
YES;
}
//UIAlertView
//-(void)actal:(UIButton *)sender
//{
// UIAlertView * alv = [[UIAlertView alloc]initWithTitle:@"标题" message:@"消息" delegate:self cancelButtonTitle:@"取消"
otherButtonTitles:@"其他", nil];
// [alv show];
//}
//UIActionSheet
//-(void)actlist:(UIButton *)sender
//{
// UIActionSheet *she = [[UIActionSheet alloc]initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destru" otherButtonTitles:@"other", nil];
// [she showInView:self.window];
//}
在ios8中
- (void)viewDidLoad {
[super
viewDidLoad];
UIButton *but3 = [[UIButton
alloc]initWithFrame:CGRectMake(170,
250, 150,
30)];
[but3 setTitle:@"表"
forState:UIControlStateNormal];
but3.backgroundColor=[UIColor
blackColor];
[but3 addTarget:self
action:@selector(actllist:)
forControlEvents:UIControlEventTouchUpInside];
//在viewcontroller视图下
[self.view
addSubview:but3];
}
-(void)actllist:(UIButton *)sender
{
// UIAlertController UIAlertAction
UIAlertController * alt =[UIAlertController
alertControllerWithTitle:@"title"
message:@"mes"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * cancelbuttion = [UIAlertAction
actionWithTitle:@"got it"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {
NSLog(@"cancel hhh");
}];
//alt add cancelvuttion
[alt addAction:cancelbuttion];
[self
presentViewController:alt
animated:NO
completion:nil];
}
*)launchOptions {
// Override point for customization after application launch.
// self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
// self.window.backgroundColor=[UIColor whiteColor];
//创建两个按钮
// UIButton *but1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, 150, 30)];
// [but1 setTitle:@"警报" forState:UIControlStateNormal];
// but1.backgroundColor=[UIColor blackColor];
//
// [but1 addTarget:self action:@selector(actal:) forControlEvents:UIControlEventTouchUpInside];
// UIButton *but2 = [[UIButton alloc]initWithFrame:CGRectMake(170, 50, 150, 30)];
// [but2 setTitle:@"操作表" forState:UIControlStateNormal];
// but2.backgroundColor=[UIColor blackColor];
// [but2 addTarget:self action:@selector(actlist:) forControlEvents:UIControlEventTouchUpInside];
//
// [self.window addSubview:but1];
// [self.window addSubview:but2];
// [self.window makeKeyAndVisible];
return
YES;
}
//UIAlertView
//-(void)actal:(UIButton *)sender
//{
// UIAlertView * alv = [[UIAlertView alloc]initWithTitle:@"标题" message:@"消息" delegate:self cancelButtonTitle:@"取消"
otherButtonTitles:@"其他", nil];
// [alv show];
//}
//UIActionSheet
//-(void)actlist:(UIButton *)sender
//{
// UIActionSheet *she = [[UIActionSheet alloc]initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destru" otherButtonTitles:@"other", nil];
// [she showInView:self.window];
//}
在ios8中
- (void)viewDidLoad {
[super
viewDidLoad];
UIButton *but3 = [[UIButton
alloc]initWithFrame:CGRectMake(170,
250, 150,
30)];
[but3 setTitle:@"表"
forState:UIControlStateNormal];
but3.backgroundColor=[UIColor
blackColor];
[but3 addTarget:self
action:@selector(actllist:)
forControlEvents:UIControlEventTouchUpInside];
//在viewcontroller视图下
[self.view
addSubview:but3];
}
-(void)actllist:(UIButton *)sender
{
// UIAlertController UIAlertAction
UIAlertController * alt =[UIAlertController
alertControllerWithTitle:@"title"
message:@"mes"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * cancelbuttion = [UIAlertAction
actionWithTitle:@"got it"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {
NSLog(@"cancel hhh");
}];
//alt add cancelvuttion
[alt addAction:cancelbuttion];
[self
presentViewController:alt
animated:NO
completion:nil];
}
相关文章推荐
- The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server
- UIButton的竖排图片和文本
- QtQuick学习笔记(三)组件
- UITouch
- 【UIKit-124-2】#import <UIKit/UIView.h>
- 认识基本的UI资源
- POJ 1904 King's Quest(强连通分量+匹配)
- Distinct Subsequences——Leetcode
- Git可视化极简易教程 — Git GUI使用方法
- does not contain bitcode. You must rebuild it with
- 远丰MallBuilder:促进线上线下融合发展
- 上海远丰ExpBuilder :助企业布局跨境电商
- GCD-创建queue的特殊参数DISPATCH_QUEUE_SERIAL
- 【UIKit-124-1】#import <UIKit/UIView.h>
- 在UITextView上写入手机图库中的图片
- QtQuick学习笔记(二)QML基本语法
- apue3 搭建(基于ubuntu 12.04LTS)
- 植物大战僵尸一:多线程修改UI界面,游戏必备API
- IOS开发中针对UIImageView的几种常用手势
- UI:数据的解析