I have updated Xcode 6.3 and ios8.3 check my code. then it gives me weird result.
here is first screen of my demo app. here is one textfield. when I type somethin in textfield keyboard open.
after typing completed. I have clicked on show alert button. I have displayed alert and output will be following.
After click on cancel. I have displayed another alert then weird result keyboard should not open but when click on cancel button. display another alert and keyboard will appear automatically.
here is next screen output
following is the code
- (IBAction)MethodShowAlert:(id)sender
{
[tmptxtField resignFirstResponder];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Check Alert textField" message:@"keyboard should not be open" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[self showCustomAlertWithTitle:nil];
}
-(void)showCustomAlertWithTitle:(NSString *)title{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Now Check" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alertView show]
}
In my case i tried hiding keyboard, before showing alert, so it will not save keyboard in memory to present it again after dismissing it self.
for that you just need to dismiss keyboard which will take default animation time to hide, only then you should present alert view then it will not save that keyboard.
you must put around .6 second gap in hiding keyboard and presenting alert
[YOUR_TEXT resignFirstResponder];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
_alertVw = [[UIAlertView alloc] initWithTitle:@"" message:@"message." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[_alertVw show];
});