UIAlertView是这样用滴:
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"温馨提示"message:@"数据不能为空"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
[alert show];
-------------------------------------------------------------------------------------
UIAlertController是这样用滴:
//创建提示框窗口
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"温馨提示"message:@"信息"preferredStyle:UIAlertControllerStyleAlert];
//实例化取消按钮
UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *action) {
}];
//实例化确定按钮
UIAlertAction *otherAction = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
}];
//向弹出框中添加按钮
[alertController addAction:cancelAction];
[alertController addAction:otherAction];
//将提示框弹出
[selfpresentViewController:alertControlleranimated:YEScompletion:nil];
//添加输入框
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.backgroundColor = [UIColorgreenColor];
textField.placeholder =@"输入点什么";
}];
//确定按钮中获得输入的内容
UITextField*textfield=alertController.textFields[0];
NSString *str = textfield.text;
NSLog(@"输入的内容:%@",str);