How to Hide keyBoard on return button itself in TextView in iPhone sdk?
In my iPhone App I am开发者_JAVA百科 using the control UItextView, I want to hide the keyBoard on "return" Button itself, I am not using any toolBar,NavigationBar and I don't want to import any other control like button on that View.
What shold I do to hide keyboard ?
Please Help and Suggest,
Thanks
You can use the shouldChangeTextInRange
delegate and look for a line break:
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)string
{
if([string isEqualToString:@"\n"]){
[textView resignFirstResponder];
}
return YES;
}
精彩评论