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. sparkStreaming与Kafka整合

    createStream那几个参数折腾了我好久..网上都是一带而过,最终才搞懂..关于sparkStreaming的还是太少,最终尝试成功... 首先启动zookeeper ./bin/zookeep ...

  2. 回调--一个经典例子让你彻彻底底理解java回调机制

    本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/17483273),请尊重他人的辛勤劳动成果,谢谢 以前不理解什么叫回调 ...

  3. JAVA 99乘法表实例

    实例: public class Test{ public static void main(String[] args){ for(int i=1;i<=9;i++){ for(int j=1 ...

  4. Java8之默认方法和静态接口方法

    前言 上一篇文章30分钟入门Java8之lambda表达式,我们学习了lambda表达式.现在继续Java8新语言特性的学习,今天,我们要学习的是默认方法和静态接口方法. 这一Java8的新语言特性, ...

  5. jquery实现的下拉和收缩代码实例

    <!DOCTYPE html>  <html>  <head>  <meta charset=" utf-8">  <meta ...

  6. dom4j-full.jar 解析 XML

    dom4j-full.jar 解析 XML public Document getDocument() throws DocumentException { SAXReader read=new SA ...

  7. iOS UIWebView 捕获403 、404错误

    #pragma mark -#pragma mark - UIWebView Delegate Methods- (BOOL)webView:(UIWebView *)webView shouldSt ...

  8. Java中的装箱拆箱

    一)  装箱与拆箱 Java中有概念是一切皆对象,因为所有的类都默认继承自Object.但是,对于数据类型是个例外,如short,int,long,float,double, byte,char,bo ...

  9. jQuery的jsonp跨域是这么回事.

    实现跨域请求的有iframe,img,script中的src属性.那么jquery是如何解决跨域请求的呢? 一:项目jsonp2中有个app.js文件,代码如下: function app(json) ...

  10. mysql数据库同步

    mysql数据库同步  1.1. Master 设置步骤 配置 my.cnf 文件 确保主服务器主机上my.cnf文件的[mysqld]部分包括一个log-bin选项.该部分还应有一个server-i ...