Open Mamonaku opened 9 years ago
mmm ... not sure this is going to fly... this is the action configuration, is there like a call back function that is always called by DAActionController, prior to firing the selected action ?
if you want 2 text boxes, you can use login style, but set second item secureTextEntry to NO, refer to http://forums.macrumors.com/threads/uialertviews-with-textfields.1355954/
I handled it like this:
__block UITextField* nameHandler;
DAAlertAction *cancelAction = [DAAlertAction actionWithTitle:@"Cancel" style:DAAlertActionStyleDestructive handler:nil];
DAAlertAction *okAction = [DAAlertAction actionWithTitle:@"OK" style:DAAlertActionStyleDefault handler:^{
// work with it
NSString * username = nameHandler.text;
}];
[DAAlertController showAlertViewInViewController:self
withTitle:@"Title"
message:@"Message"
actions:@[okAction, cancelAction]
numberOfTextFields:1
textFieldsConfigurationHandler:^(NSArray *textFields) {
nameHandler = [textFields firstObject]; // set the pointer
}
validationBlock:^BOOL(NSArray *textFields) {
UITextField *nickNameTextField = [textFields firstObject];
return nickNameTextField.text.length >= 3;
}];
@damaex 's solution is a correct one with the usage of __block as we'd like to use a variable outside the scope of the block. I suppose it's a weakness of this polished code so I advice to Daria to include a more elegant version for this evident problem.
Hi Daria,
congrats on this very useful component ! I'd like to have one of the textField.text
send back to
where response is a dictionary with @{@"1":@"value of textField number 1"} etc....
In your code DAAlertController.m there is
to which I can add
My question to you is: Where do I get to find the textField attributes in DAAlertController.m ?
thank you !