在开发中我们经常会遇到要提示用户信息的地方,这是就用到了AlertView了。但是在ios8以后AlertView就不在是被弃用了变成了一个控制器了AlertViewController,使用方法也有点发生变化,下面是太输入框的提示框的代码示例
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入场景名称" message:@"输出" preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
}];
UIAlertAction *Action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *twoAc = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
_senceText = (UITextField *)alert.textFields.firstObject;
}];
[alert addAction:Action];
[alert addAction:twoAc];
[self presentViewController:alert animated:YES completion:nil];
}