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. Redis简介及3.0.2编译安装

    由于项目需要Redis作为内存数据库,所以也开始搞Redis~ Redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).l ...

  2. IGS_学习笔记05_IREP开发Concurrent Program为客户化集合接口(案例)

    20150819 Created By BaoXinjian

  3. codeforces 439 E. Devu and Birthday Celebration 组合数学 容斥定理

    题意: q个询问,每一个询问给出2个数sum,n 1 <= q <= 10^5, 1 <= n <= sum <= 10^5 对于每一个询问,求满足下列条件的数组的方案数 ...

  4. 启动mongoDB 以及常用操作命令

    nonsql    关系数据库 集合  表 文档 行 启动mongoDB之前首先手动创建存放MongoDB数据文件的目录,如e:\mongo_data 执行命令  mongod --dbpath=e: ...

  5. Python2.7.5 安装(转载)

    From:http://www.cnblogs.com/balaamwe/p/3480430.html From:http://www.chgon.com/?p=1340 安装python2.7.5纠 ...

  6. centos update git(转载)

    From:http://itekblog.com/update-git-centos/ 1.下载RPMForge repo cd /tmp # bit: wget http://pkgs.repofo ...

  7. Log4net中的RollingFileAppender z

    Log4日志组件的应用确实简单实用,在比较了企业库和Log4的日志功能后,个人觉得Log4的功能更加强大点.补充说明下,我使用的企业库是2.0版本,Log4net是1.2.1版本的. 在Log4net ...

  8. HttpClient和WebService的区别和介绍

    1. HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.  HttpClient用来调用服务,它是模拟 ...

  9. Struts中<s:checkboxlist>的用法

    一.JSP中 ①集合为list <s:checkboxlist name="list" list="{'Java','.Net','RoR','PHP'}" ...

  10. CentOS 安装 Chrome

    cd  /etc/yum.repos.d/ vi  google.repo [gogle] name=Google-x86_64 baseurl=http://dl.google.com/linux/ ...