UIAlertViewController的使用方法

    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];

你可能感兴趣的:(UIAlertViewController的使用方法)