image.png
image.png
#pragma Mrhan- 測試彈框中纸型,添加編輯框
- (void)jq_addTextFieldMethod {
/**
UIAlertController must have a title, a message or an action to display
注意:
1备籽,UIAlertController至少有一個title/message/action
2暑始,UIAlertController添加textfield的時候菩掏,必須是UIAlertControllerStyleAlert類型郁稍,而不能是UIAlertControllerStyleActionSheet類型
*/
UIAlertController *alerVC = [UIAlertController alertControllerWithTitle:@"個人資料" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alerVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請輸入姓名";
}];
[alerVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請輸入年齡";
}];
[alerVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請輸入性別";
}];
[alerVC addAction:[UIAlertAction actionWithTitle:@"確定" style:(UIAlertActionStyleDestructive) handler:^(UIAlertAction * _Nonnull action) {
UITextField *textfield1 = alerVC.textFields[0];
UITextField *textfield2 = alerVC.textFields[1];
UITextField *textfield3 = alerVC.textFields[2];
NSLog(@"textfield1-%@,textfield2-%@,textfield3-%@",textfield1.text,textfield2.text,textfield3.text);
}]];
[self presentViewController:alerVC animated:YES completion:nil];
}