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]
}
Select the iOS simulator window by click it. Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator.
Sometimes, you’re using an iPad but the onscreen keyboard doesn’t show up where you expect it. There could be one of several things going on, including trouble with a Bluetooth keyboard or third-party keyboard apps. Here’s what may be wrong—and how to fix it.
Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator. 2. Fix iOS Simulator Keyboard Hidden Issue Method Two.
Use Auto Correction on iPhone How to use Auto-Correction and predictive text on your iPhone, iPad, or iPod touch - Use Auto-Correction 1 Open the Settings app. 2 Tap General > Keyboard. 3 Turn on Auto-Correction. By default, Auto-Correction is on. See More....
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];
});
Yep, it's strange.
But since iOS 8, I suggest to use the UIAlertController instead of UIAlertView.
Replace your code with this one:
- (IBAction)MethodShowAlert:(id)sender
{
[tmptxtField resignFirstResponder];
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"Check Alert textField"
message:@"keyboard should not be open"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self showCustomAlertWithTitle:@"Now Check"];
}];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
}
-(void)showCustomAlertWithTitle:(NSString *)title{
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:title
message:nil
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertController animated:YES completion:nil];
}
The keyboard will not show after the click on the button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With