From past few days I am facing a weird keyboard
issue that is only happening in iPhone 5c
only.
I am using objective-C
for Development in Xcode-6.4
My environment target is ios7
.
Here is How I am handeling keyboard Notification
.
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
To Deregister Notification
I am writing this piece of code.To be sure I use -resignFirstResponder
for every textField.
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self hideKeyBoard];
[self.view endEditing:YES];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
- (void)hideKeyBoard{
[kAgeTextField resignFirstResponder];
[kSchoolTextField resignFirstResponder];
}
And In submit button I have checked some condition and then I am showing an AlertView
.
- (IBAction)submitClicked:(id)sender
{
if(validated)
{
[self.view endEditing:YES];
[self hideKeyBoard];
[self.view resignFirstResponder];
[self makeApiCall];
}
}
Now when I get Success/Failure Response from server I am doing this.This is the block which runs after getting response from server:
-(void)SuccessfulWithServerInfo:(id)responseInfo
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
dispatch_async(dispatch_get_main_queue(),^{
[appDelegate hideProgressViewFromView:self.view];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"Thanks for coming" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[self.navigationController popToRootViewControllerAnimated:YES];
});
}
Problem When I get alertBox and press ok. Then keyboard opens up and closes automatically. This is happening i iPhone 5C only. I checked it in 4s,5s,6 and 6Plus. All are working fine.
If anyone knows about it please assist.