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. ...
随机推荐
- win7,xp通用的打开文件浏览对话框的方法
第一种:Function BrowseForFile() Dim shell : Set shell = CreateObject("WScript.Shell") ...
- SQL笔记-第三章,数据的增删改
1.数据的插入 简单的INSERT语句 INSERT INTO T_Person(FName,FAge,FRemark) VALUES(‘Tom’,18,’USA’) 简化的INSERT语句(只对部分 ...
- mysql Can't connet MySQL server to '@localhost'
10063/10060/10038好像都能解决 mysql -nt -remove mysql -nt install
- Hue整合Sqoop报空指针异常的解决方法
hue是一个Apache基金会下的一个开源图形化管理工具,使用python语言开发,使用的框架是Django.而sqoop也是Apache的一个开源工具,是使用Java语言开发,主要用于进行hdfs和 ...
- CentOS网络配置详解
转载于CentOS中文站:http://www.centoscn.com/CentOS/2015/0507/5376.html一.配置文件详解 在RHEL或者CentOS等Redhat系的Linux系 ...
- BCB中获得RichEdit 默认行间距
首先,这些功能支持RichEdit2.0 以上功能: 其次,用常规的方法是无法获得LineSpace 的: 你使用 EM_GETPARAFORMAT也得不到,你会发现dyLineSpacing 的值永 ...
- information_schema系列四(跟踪,列约束,表和列)
这个系列的文章主要是为了能够让自己了解MySQL5.7的一些系统表,统一做一下备注和使用,也希望分享出来让大家能够有一点点的受益. 1:KEY_COLUMN_USAGE 按照官方的解释,这个表描述的是 ...
- 简单的javascript--test2
插件: jquery, sweetalert (http://t4t5.github.io/sweetalert/ ) 1.index.html <!DOCTYPE HTML> <h ...
- linux 驱动学习笔记01--Linux 内核的编译
由于用的学习材料是<linux设备驱动开发详解(第二版)>,所以linux驱动学习笔记大部分文字描述来自于这本书,学习笔记系列用于自己学习理解的一种查阅和复习方式. #make confi ...
- HTTP返回值
100 Continue:初始的请求已经接受,客户应当继续发送请求的其余部分. 101 Switching Protocols:服务器将遵从客户的请求转换到另外一种协议. 200 OK:一切正常,对G ...