UIAlertViewController的使用方法

来源:互联网 发布:淘宝怎么换购产品 编辑:程序博客网 时间:2024/06/06 08:46
    UIAlertController *alertcontroller = [UIAlertController alertControllerWithTitle:@"你" message:@"杀人啦" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击“确定”后执行");
    }];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击“取消”后执行");
    }];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"啊啊" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击“啊啊”后执行");
    }];
    [alertcontroller addAction:action2];
    [alertcontroller addAction:action];
    [alertcontroller addAction:action1];
    [alertcontroller addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {//UIAlertControllerStyleAlert情况下使用
        textField.placeholder = @"登录";
    }];
    [alertcontroller addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = @"啊啊";
    }];
    
    [self presentViewController:alertcontroller animated:YES completion:nil];
0 0
原创粉丝点击