UIAlertView、 UIActionSheet
一、UIAlertView、 UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlertView与AUIctionSheet最大的区别在于UIAlertView是表现为显示在屏幕中央的弹出式警告框,而 ActionSheet表现为显示在屏幕底部的按钮列表。
1、创建UIAlertView。创建该对象时可致定改警告框的标题、消息内容、以及该警告框包含几个按钮等信息。如果程序需要监听用户点击饿警告框时那一个按钮,则需要在创建该UIAlertView时设置UIAlertViewDelegate委托对象。
2、调用UIAlertView显示。
3、如果需要监听用户点击了警告狂的那个按钮,则需为UIAlertViewDelegate协议中的方法。
二、UIActionSheet
UIActionSheet表现为显示在底部的按钮列表,用户通过单击某个按钮来表明自己的态度。默认情况下UIActionSheet只支持一个标题和多个按钮,UIActionSheet会有两个固定的按钮和多个其它按钮。
1、其创建与UIAlertView基本一致
三、具体代码如下:(包含相关的属性)
[alert show];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld",(long)buttonIndex);
btn.backgroundColor = [UIColor grayColor];
btn.frame = CGRectMake(10, 20, 80, 80);
[btn addTarget:self action:@selector(showAlert) forControlEvents:UIControlEventTouchUpInside];
if (textField.tag == 1) {
// [self showAlert];
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"男",@"女", nil];
action.tag = 3;
[action showInView:self.view];
[textField resignFirstResponder];
}
}
-(void)showAlert{
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"建行",@"农行", nil];
action.tag = 4;
[action showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"=====%zi",buttonIndex);
NSLog(@"---->%@",[actionSheet buttonTitleAtIndex:buttonIndex]);
if (actionSheet.tag == 3) {
UITextField *field = (UITextField *)[self.view viewWithTag:1];
field.text = [actionSheet buttonTitleAtIndex:buttonIndex];
}
UIAlertView、 UIActionSheet的更多相关文章
- UIAlertView、UIActionSheet兼容iOS8
链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...
- iOS - 提示信息 - UIAlertView、UIActionSheet、UIAlertController的实际应用
1.UIAlertView(屏幕中央弹出框)(不需要服从代理) UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@" ...
- iOS改变UIAlertView、UIActionSheet、UIAlertController系统字体颜色
废话不多说,直接上代码,效果是最好的说服力 1.改变UIAlertView字体颜色 [UIView appearance].tintColor = [UIColor greenColor]; 个人还是 ...
- UIAlertView 与 UIActionSheet (提示用户)的使用方法
UIAlertView 提示用户 帮助用户选择框 // UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...
- iOS 8 中 UIAlertView 和 UIActionSheet 河里去了?
iOS 8 中 UIAlertView 和 UIActionSheet 河里去了? 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...
- iOS:简单使用UIAlertVIew和UIActionSheet
做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...
- iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet
UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...
- 用block将UIAlertView与UIActionSheet统一起来
用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...
- iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建
1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...
随机推荐
- java学习第5天
一维数组完了就是二维数组,和一位数组类似 .我们定义二维数组用的是 int[] []arr=new int[m][n],与一维类似,它在堆内存中存放,并以地址的形式访问,如下图.. 而遍历二维数组 ...
- javaweb学习第一天 debug
debug 断点: f5:step into f6:step over f7:step return drop to frame:跳到当前方法的的第一行 resume:跳到下一个断点 watch:观察 ...
- C#DataGridView中的常用技巧
0(最基本的技巧). 获取某列中的某行(某单元格)中的内容 this.currentposition = this.dataGridView1.BindingContext [this.dataG ...
- nginx 启动,停止和重新加载配置
要启动nginx的,运行可执行文件.一旦nginx的启动时,它可以通过与-s参数调用可执行来控制.使用以下语法 nginx -s signal 其中,信号可以是下列之一: stop - fast sh ...
- Windows service无法删除怎么办?
自己用c#创建的windows service, 安装后,执行installutil /u 状态变成disable,却删除不了.删除的时候提示"The specified service ...
- Spring HtmlUtils把HTML编码转义,可将HTML标签互相转义
Spring HtmlUtils把HTML编码转义,可将HTML标签互相转义 2014年09月05日 ⁄ 综合 ⁄ 共 372字 ⁄ 字号 小 中 大 ⁄ 评论关闭 org.springframe ...
- HTML速查列表
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- addClass() 和 toggleClass()
addClass()是在原有的类基础上增加类属性,仍然保留原有的类的样式.语法格式为:addClass(class0 class1 ...) ,例如: $("p").addClas ...
- html() 和 text() 方法的区别
html()方法仅支持XHTML的文档,不能用于XML文档,而text()既支持HTML文档,也 支持XML文档. html():没有参数,用于获取html的值: html(val):有参数,用于设置 ...
- DrawerLayout学习,抽屉效果
第一节: 注意事项 *主视图一定要是DrawerLayout的第一子视图 *主视图宽度和高度匹配父视图,因为当你显示主视图时,要铺满整个屏幕,用户体验度较高 *必须显示指定的抽屉视图的android: ...