直接上代码:
一、底部弹出框:
UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:nil message:@"确认修改设备名称?" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[actionSheetController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
//增加取消按钮;
[self presentViewController:actionSheetController animated:true completion:nil];
二、中间弹出框:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"修改名称" message:@"请输入设备的名称" preferredStyle:UIAlertControllerStyleAlert];
//增加取消按钮;
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
//增加确定按钮;
[alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
}]];
//定义第一个输入框;
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"请输入传感器名称";
//textField.delegate = self;
}];
[self presentViewController:alertController animated:true completion:nil];