I want to realize a function about changing password. It requires users to input their previous password in an alert dialog.
I want to click the button \"Confirm the
You can add multiple textfields to alert controller and access them with the alert controller's textFields
property
If the new password is an empty string, present the alert again. Or another way would be to disable the "Confirm" button, enabling it only when text field has text.
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"confirm the modification" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
UITextField *password = alertController.textFields.firstObject;
if (![password.text isEqualToString:@""]) {
//change password
}
else{
[self presentViewController:alertController animated:YES completion:nil];
}
}];