UIAlertView:

1.普通使用:

//普通的alert

UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];

[av show];

2.UIAlertView还可以设置其样式:

如果可以输入账号与密码的样式:

//普通的alert

UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];

[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];//设置样式:明文与暗文

[av show];

3.判断用户点击了alert的哪个按钮的协议:

//协议:alertView

//判断用户点击了alert的那个按钮

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

if(buttonIndex == 0)

{

NSLog(@"you click no");

}

else

{

NSLog(@"you click yes");

}

}

4.   常用方法总结:

  1. //根据被点击按钮的索引处理点击事件
  2. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  3. {
  4. NSLog(@"clickButtonAtIndex:%d",buttonIndex);
  5. }
  6. //AlertView已经消失时执行的事件
  7. -(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
  8. {
  9. NSLog(@"didDismissWithButtonIndex");
  10. }
  11. //ALertView即将消失时的事件
  12. -(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
  13. {
  14. NSLog(@"willDismissWithButtonIndex");
  15. }
  16. //AlertView的取消按钮的事件
  17. -(void)alertViewCancel:(UIAlertView *)alertView
  18. {
  19. NSLog(@"alertViewCancel");
  20. }
  21. //AlertView已经显示时的事件
  22. -(void)didPresentAlertView:(UIAlertView *)alertView
  23. {
  24. NSLog(@"didPresentAlertView");
  25. }
  26. //AlertView即将显示时
  27. -(void)willPresentAlertView:(UIAlertView *)alertView
  28. {
  29. NSLog(@"willPresentAlertView");
  30. }

iOS之UIAlertView的使用的更多相关文章

  1. ios之UIAlertView

    举例: UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Default Alert View"messa ...

  2. 【iOS】UIAlertView 点击跳转事件

    iOS 开发中,UIAlertView 经常用到.这里记录下曾用到的点击跳转事件. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@& ...

  3. iOS - 提示信息 - UIAlertView、UIActionSheet、UIAlertController的实际应用

    1.UIAlertView(屏幕中央弹出框)(不需要服从代理) UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@" ...

  4. IOS开发:UIAlertView使用

    链接地址:http://www.2cto.com/kf/201307/231841.html UIAlertView是什么就不介绍了 1.基本用法 1 UIAlertView *view = [[UI ...

  5. IOS对话框UIAlertView

    //修改弹出对话框的样式 alertView.alertViewStyle = UIAlertViewStylePlainTextInput; //根据索引获取指定的某个文本框 [alertView ...

  6. IOS Using UIAlertView to show alerts

    UIAlertView in other words, it's a dialog box. You want to show a message or ask user to confirm an ...

  7. iOS改变UIAlertView、UIActionSheet、UIAlertController系统字体颜色

    废话不多说,直接上代码,效果是最好的说服力 1.改变UIAlertView字体颜色 [UIView appearance].tintColor = [UIColor greenColor]; 个人还是 ...

  8. IOS中UIAlertView(警告框)常用方法总结

    一.初始化方法 - (instancetype)initWithTitle:(NSString *)title message:(NSString*)message delegate:(id /*&l ...

  9. IOS UIAlertView(警告框)方法总结

    转自:my.oschina.net/u/2340880/blog/408873?p=1 IOS中UIAlertView(警告框)常用方法总结 一.初始化方法 - (instancetype)initW ...

随机推荐

  1. RMAN_Oracle RMAN的常用Command命令

    2014-12-11 Created By BaoXinjian

  2. 读取缓存模拟----FIFO

    本例是模拟缓存的存储和读取. 存储:使用一个Map来存放,key是文件名,值为缓存对象 读取:返回相应的key对应的缓存.(如果缓存被修改,就重新加载缓存,再从缓存Map中读取相应缓存) 测试类:每2 ...

  3. 什么是bower

    Bower是一个客户端技术的软件包管理器,它可用于搜索.安装和卸载如JavaScript.HTML.CSS之类的网络资源.其他一些建立在Bower基础之上的开发工具,如YeoMan和Grunt,这个会 ...

  4. C++学习15 继承权限和继承方式

    C++继承的一般语法为: class 派生类名:[继承方式] 基类名{ 派生类新增加的成员 }; 继承方式限定了基类成员在派生类中的访问权限,包括 public(公有的).private(私有的)和 ...

  5. [ActionScript 3.0] as3可以通过CDATA标签声明多行字符串

    var str:String=<![CDATA[YANSHUANGPING yanshuangping yanshuangping ]]>; trace(str); var myname: ...

  6. eclipse快速收缩展开代码

    快速折叠所有代码和展开所有代码都是CTRL+SHIFT+/

  7. android 4.4 状态栏隐藏

    这个是Android Developer上的原文 反正我也看得不是很懂 我知道的就是实现和导航栏和状态栏的透明 带一些渐变效果 1. 设置主题 <style name="Theme.T ...

  8. Codeforces 633D

    题意: 给定n,和一个长度为n的序列. 让你在这n个数中找长度尽可能长的fib数列. 思路: 这题的数字是在1e9范围内的,所以最长的可能存在的fib数列官方的解释是90左右.有一种情况除外,就是0的 ...

  9. (easy)LeetCode 232.Implement Queue using Stacks

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  10. 【转】Bash脚本实现批量作业并行化

    首先附上自己常用的代码 ---------------------------------------------------------------------------------------- ...