Sir On Tap Gesture I am hide Keyboard.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
They work fine. But when we edit textView second time.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
call multiple time. And they execute my code 5-6 time inside keyboardWillBeHidden. Is their any way they not call when textview begin edit.
- (void)textViewDidBeginEditing:(UITextView *)textView
{
if ([textView.text isEqualToString:@"Type your message Here..."]) {
textView.text = @"";
textView.textColor = [UIColor grayColor]; //optional
}
[self scrollToBottomAnimated:YES];
}
- (void)scrollToBottomAnimated:(BOOL)animated
{
NSInteger rows = [tableViews numberOfRowsInSection:0];
if(rows > 0) {
[tableViews scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:rows - 1 inSection:0]
atScrollPosition:UITableViewScrollPositionBottom
animated:animated];
}
}