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. ...
随机推荐
- 洛谷P3374 【模板】树状数组 1
P3374 [模板]树状数组 1 140通过 232提交 题目提供者HansBug 标签 难度普及/提高- 提交 讨论 题解 最新讨论 题目描述有误 题目描述 如题,已知一个数列,你需要进行下面两 ...
- JavaScript 为什么要通过原型 prototype 调用函数, 而不是直接调用?
现象 经常在网上或者阅读源码时看到下面的代码: Array.prototype.slice.call(arr, 3); 而不是 arr.slice(3); 原因 这是为什么呢, 毕竟下面这种方法更短, ...
- winform.布局
布局:默认布局:自己拖动进行布局,工具栏里对齐方式 右键,锁定.##随容器拉动变化属性:Anchor:上下左右,固定的设置 panel的排列 1.Dock属性:(顺序填充)Top:靠上,高度不变,左右 ...
- ubuntu 14.04 更新 gcc/g++ 4.9.2
ubuntu 14.04 更新 gcc/g++ 4.9.2 最近看到c++11非常的好用,尤其是自带了regex,于是稍微学了一下c++11的新特性.可是我在编译一个regex程序是却发现稍微复杂一点 ...
- hive中的一些参数
动态分区 设置如下参数开启动态分区:hive.exec.dynamic.partition=true默认值:false描述:是否允许动态分区hive.exec.dynamic.partition.mo ...
- cell的自适应
+(CGFloat)getCellHeightWithItem:(FXOwnershipStrutureInfo *)item { if (item.rowH) {//如有rowH就直接返回,避免重新 ...
- C++中 容易忽视的const 修饰符
C++可以用const定义常量,也可以用#define定义常量,但是前者比后者有更多的有点: (1)const常量有数据类型,而宏常量没有数据类型.编译器可以对const进行类型安全检查,而后者只进行 ...
- [转]libsvm 训练后的模型参数讲解
http://blog.sina.com.cn/s/blog_6646924501018fqc.html 主要就是讲解利用libsvm-mat工具箱建立分类(回归模型)后,得到的模型model里面参数 ...
- UI组件之Group
当Group旋转或缩放时,它的孩子们正常绘制,并且Batch变换后正确的旋转或缩放. 绘制Group前,Batch flush使得变换可以设置.有很多Group时这将可能成为性能瓶颈.如果在一组演员不 ...
- 慕课网JavaScript入门篇课程笔记
1.js注释很重要 单行注释,在注释内容前加符号 “//”. <script type="text/javascript"> document.write(" ...