Please help me with below issue.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Check" message:@"What was the value collected?" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField)
{
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.placeholder = @"What was the value collected?";
}];
[alertController addAction:[UIAlertAction actionWithTitle:@"Submit" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
UITextField *txtValue = alertController.textFields.firstObject;
toCollect = [txtValue.text floatValue];
}]];
[self presentViewController:alertController animated:YES completion:nil];
I have using above code but it shows me result in below screenshot. Not able to display title and message
Thanks in advance !
I was tested your code which you posted on here and thats work fine in all simulator as well as devices also in iOS 8.0+ OR if you want to test it in ios 7.0 then you have to use UIAlertview.
Code is : view controller.m
Snaps of Output :
Here it is the code for create
UIAlertController
for showing Message and title.For swift you can do same thing like following code:
Download Demo from Github: https://github.com/nitingohel/NGAlertViewController-Swift2.0
To be frank your code is working fine. Just a hunch, try adding
[self presentViewController:alertController animated:YES completion:nil];
this piece of code on main queue.I modified your code a bit and it worked for me. Basically, I used "show" controller instead of "present".
Here is the snip:
Try this code for that.