Ok I have exhausted google and this site looking for an answer and cannot find one. I currently have a UITextView (postMessage) and the keyboard for it will not disappear. I have tried every possible code combination to make it dismiss but it simply will not.
I have tried doing the return key method
- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if([text isEqualToString:@"\n"]){
//MainViewController *mvc = [[MainViewController alloc] init];
//[mvc.view endEditing:YES];
//[[self view] endEditing: YES];
//[self.postMessage becomeFirstResponder];
//[self.topLayer endEditing:YES];
//[self.view endEditing:YES];
//[self.collectionView endEditing:YES];
//[self.postMessage.editable = NO];
//[postMessage resignFirstResponder];
[self.postMessage resignFirstResponder];
return NO;
}else{
return YES;
}
}
I also have tried using a UIToolBar with a UIBarButton
-(IBAction)done:(id)sender {
[self keyboardIsHidden];
[[self view] endEditing: YES];
[self.postMessage becomeFirstResponder];
[self.topLayer endEditing:YES];
[self.view endEditing:YES];
[self.collectionView endEditing:YES];
//[self.postMessage.editable = NO];
[self.postMessage resignFirstResponder];
keyboardBar.hidden = YES;
NSLog(@"done");
}
And nothing..... I have used NSLogs to make sure that both methods are being called, but the keyboard will not resign. I have also use and if statement to check to make sure the UITextView (postMessage) is firstResponder and it is.
In my project I have 2 views (not view controllers) a bottom layer view and top layer. The user pulls the top layer up into view. I also have a UICollectionView.
I have noticed that when I press the return key on the keyboard or the 'Done' key on my UIToolBar the UICollectionView reloads the data.
I do have the UITextViewDelegate set on the .h. I also have postMessage.delegate = self in my ViewDidLoad
Thanks! -Mike