UIAlertView常用属性(9.0起失效)

UIAlertView的继承关系:
UIAlertView:UIView:UIResponder:NSObject

- (void)viewDidLoad
{
    [super viewDidLoad];

    /**
     1、初始化

     - initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:
     */
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示框"
                                                       message:@"这是我测试的一个提示框"
                                                      delegate:self
                                             cancelButtonTitle:@"取消"
                                             otherButtonTitles:@"确定", nil];


    /**
     2、设置属性

         .alertViewStyle    //设置类型  UIAlertViewStyleDefault默认、 
                                                       SecureTextInput密码输入框、
                                                       PlainTextInput普通输入框、
                                                       LoginAndPasswordInput账号密码框
         .title             //设置标题
         .message           //设置消息
         .visible           //获取是否显示,判断控件是否显示 (只读属性)
     */
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    NSLog(@"title:%@",  alertView.title);
    NSLog(@"message:%@",alertView.message);
    NSLog(@"visible:%d",alertView.visible);


    /**
     3、配置按钮

         - addButtonWithTitle:  //添加新的按钮

         - buttonTitleAtIndex:  //根据索引,获取按钮的标题
         - textFieldAtIndex:    //根据索引,获取文本输入框的内容

         .numberOfButtons       //总的按钮数
         .cancelButtonIndex     //取消按钮的index
         .firstOtherButtonIndex //第一个其他按钮的index
     */
    [alertView addButtonWithTitle:@"完成"];

    NSLog(@"buttonTitleAtIndex:%@",     [alertView buttonTitleAtIndex:1]);

    NSLog(@"numberOfButtons:%d",        alertView.numberOfButtons);
    NSLog(@"cancelButtonIndex:%d",      alertView.cancelButtonIndex);
    NSLog(@"firstOtherButtonIndex:%d",  alertView.firstOtherButtonIndex);


    /**
     4、显示

         - show
     */
    [alertView show];

    /**
     5、回收AlertView

         - dismissWithClickedButtonIndex:animated:
     */


    /**
     6、代理

         .delegate

         - alertView:clickedButtonAtIndex:          //点击按钮时触发的方法

         - alertViewShouldEnableFirstOtherButton:   //设置是否允许第一个按钮不是取消按钮

         - willPresentAlertView:                    //将要展现警告框时触发的方法
         - didPresentAlertView:                     //已经展现警告框时触发的方法

         - alertView:willDismissWithButtonIndex:    //警告框将要消失时触发的方法
         - alertView:didDismissWithButtonIndex:     //警告框已经消失时触发的方法

         - alertViewCancel:                         //alertView消失前要执行的行为。
     */

}

这里写图片描述 这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值