How can i hide the keyboard when the uitextView is in focus~~

I hava a UITextView ,and after some characters' input, I want to use a button click to hide the keyboard and the UITextView is still in focus....[Attention:the button is not a return key or a done key];

Answers


Have you set delegate to your UITextView instance? If so, try using [_textView resignFirstResponder];

else

Try using [self.view endEditing:YES];


mplement following code to your view controller .m file & .h file add delegate of textView

 -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
  if([text isEqualToString:@"\n"])
    [textView resignFirstResponder];
  return YES;
}

Now goto interface builder, select your textview & set return key type done.


Need Your Help

IE 8 not showing .aspx files?

c# vb.net internet-explorer

I use VB and program in C#.net. I change a file, rebuild my solution, and use IE 8 on my desktop to show my changes. My server uses IIs 7.5. This problem started yesturday mid day. I can open the

How to make an HTML <a> tag so that search engine crawlers don't access them

javascript html hyperlink search-engine

My problem is about HTML links (the anchor tag) and web search engines. As far as I know, web crawlers accesses all or most of the links inside a page when indexing that page, right? What if I wanted