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. Form_Form Builder Export导出为Excel(案例)

    2014-01-09 Created By BaoXinjian  

  2. c++学习-多态性

    强制转换父类对象为子类 #include<iostream> #include<string> #include <typeinfo> using namespac ...

  3. centos下的一些命令

    1.查看版本 cat /etc/redhat-release 2.安装VIM yum -y install vim-enhanced 3.升级系统 yum -y update 4.把 vi 替换为 v ...

  4. 原始ajax发起请求并反馈

    在用户登陆的时候,离开用户.密码输入框即进行验证:ajax发起请求进行验证的: login.jsp代码: <%@ page language="java" contentTy ...

  5. ORA-30036

    http://blog.sina.com.cn/s/blog_676255e101018d5s.html

  6. expdp impdp终极教学

    源地址:http://blog.csdn.net/giianhui/article/details/7788550

  7. trim

    这是一个很常见的函数,他的所用是去掉字符序列左边和右边的空格,如字符串str = " ai lafu yo ";str = trim(str); cout << str ...

  8. [ActionScript 3.0] AS3 绘制立方体

    package { import flash.display.Sprite; import flash.events.Event; import flash.geom.Vector3D; import ...

  9. ROWID-Oracle中删除重复行数据

    DELETE FROM DEPT_BAK WHERE ROWID NOT IN (SELECT MIN(ROWID) RID FROM DEPT_BAK GROUP BY DEPTNO,DNAME,L ...

  10. photoshop如何选择图层?

    选择移动工具,在上边的属性栏里勾选"自动选择图层"功能即可. 只要打上勾, 并且配上是选择图层,还是组, 点到哪里就选中哪里.   参考: http://zhidao.baidu. ...