已经被iOS9无情的抛弃了的UIAlertView

虽然被抛弃了,还是要用所以还是研究了一下
下面就一起看一下,我把所有的UIAlertView的系统方法,以及系统属性全部弄了一遍,希望对大家有帮助

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"你好啊" message:@"取消" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"啊", nil];
    alert.frame = CGRectMake(0, 0, WIDTH, 300);
    alert.delegate = self;
    alert.title = @"重新定义title";
    alert.message = @"重新定义message";
    [alert addButtonWithTitle:@"不是创建的"];
    [alert addButtonWithTitle:@"不是创建的2"];
    NSLog(@"number Of Buttons :%ld",alert.numberOfButtons);//获取当前button的个数
    //获取指定索引的按钮标题
    NSLog(@"buttonTitleAtIndex1:%@",[alert buttonTitleAtIndex:0]);//title @"啊"
    NSLog(@"buttonTitleAtIndex2:%@",[alert buttonTitleAtIndex:1]);//@"ok"
    //获取取消按钮的索引
    NSLog(@"cancelButtonIndex:%ld",alert.cancelButtonIndex);
    //获取第一个其他按钮的索引
    NSLog(@"firstOtherButtonIndex:%ld",alert.firstOtherButtonIndex);
    NSLog(@"visible:%d",alert.visible);
    /*
     UIAlertViewStyleDefault = 0,
     UIAlertViewStyleSecureTextInput, 加密输入框
     UIAlertViewStylePlainTextInput,  输入框
     UIAlertViewStyleLoginAndPasswordInput 账号已经密码输入框
     */
    alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;

    [alert show];
//    [alert dismissWithClickedButtonIndex:1 animated:YES];//执行点击index为1的button

    UITextField * text = [[UITextField alloc] init];
//    text.placeholder = @"自己的textfield";
    text = [alert textFieldAtIndex:0];   // 获取index为0的textfield
    NSLog(@"%@",text.placeholder);

下面是代理方法

#pragma mark ----------------代理方法们,等待朕的君临天下吧------------
//根据被点击按钮的索引处理点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        NSLog(@"我是0");
    }
}

//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    NSLog(@"不,我不想消失,消失了");
}

//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
    NSLog(@"即将消失了");
}

//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
    NSLog(@"取消按钮");
    //
}

//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
    NSLog(@"显示");
}

//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
    NSLog(@"即将显示");
}

如果你还需要别的功能,请自定制吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值