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. adb 工具学习

    adb (android debug bridge)简单介绍: 1.adb 是 Android SDK中所带工具.使用adb,可以在PC上操作Android设备或者模拟器 2.主要功能有: 将本地ap ...

  2. JavaScript事件基础知识总结【思维导图】

    另外附上来自Nicholas C.Zakas<JavaScript高级程序设计 第3版>中的跨浏览器兼容EventUtil对象. var EventUtil = { //注册事件 addH ...

  3. 程序进入 EXPORT App_Fault_ISR的原因及措施:

    最近再UCOSIII+LPC1768上移植modbus,在定时器初始化部分竟然跑飞进入 EXPORT  App_Fault_ISR,查资料.逛论坛.问大牛都没有解决,最后发现竟然是犹豫一个低级失误引起 ...

  4. ylbtech-dbs-m-QQ邮箱

    ylbtech-dbs:ylbtech-dbs-m-QQ邮箱 -- =============================================-- DatabaseName:QQ-Em ...

  5. Getting started with SciPy for .NET

    Getting started with SciPy for .NET 1.) IronPython Download and install IronPython 2.7, this will re ...

  6. Valid Number @python

    Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...

  7. [SQL] 要查询9 月份的数据中的任意时间段,可能是一个月的,也可能是1日到15日的

    SELECT * FROM [表名] WHERE datediff(month,[列名],

  8. poj 1860 Currency Exchange :bellman-ford

    点击打开链接 Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16635   Accept ...

  9. WPF更新数据源

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windo ...

  10. BC之The mook jong

    Problem Description ZJiaQ want to become a strong man, so he decided to play the mook jong.ZJiaQ wan ...