Reputation: 5064
I have one textField
in my viewController
, when AlertViewController
is appear keyboard is not appear at in background of the AlertViewController. But After dismiss AlertViewController
Keyboard is appear. This thing happen only for ios8 device. Here is my following Code:
[textField becomeFirstResponder];
if([self checkIfiOS8])
{
// for iOS 8
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Your Title"
message:@"Your message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
else
{
// iOS7
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your Title" message:@"Your message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
Upvotes: 2
Views: 5046
Reputation: 3656
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"AlertView" message:@"I am an AlertView" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
Upvotes: 2