Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:08:16+00:00 2026-06-16T00:08:16+00:00

So i was reading the description about UITextView’s and it says that it automatically

  • 0

So i was reading the description about UITextView’s and it says that it automatically hides the keyboard when you press the ‘Return’ button on the keyboard. But it wasn’t working, so I tried creating an

- (IBAction)textViewReturn:(id)sender; 
{
   [myTextView resignFirstResponder];
}

That did not work either so i tried also doing:

- (BOOL)textViewShouldReturn:(UITextView *)textView
{
  [myTextView resignFirstResponder];
  return NO;
} 

Not sure why the whole deal isn’t working in the first place. Wondering if anyone could help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:08:17+00:00Added an answer on June 16, 2026 at 12:08 am

    I don’t see anything in the UITextView Class Reference that says it automatically hides the keyboard when you press Return.

    Also, there is no textViewShouldReturn: message in the UITextViewDelegate protocol. There is a textFieldShouldReturn: message in the UITextFieldDelegate protocol, but a text view is not a text field.

    If you want it to hide the keyboard when the user presses Return, you need to do two things.

    First, you need to connect some object – usually your view controller – to the text view’s delegate outlet. You can do that in your nib, or you can do it in code, perhaps in your viewDidLoad method:

    - (void)viewDidLoad {
        [super viewDidLoad];
        myTextView.delegate = self;
    }
    

    Second, you need to implement the textView:shouldChangeTextInRange:replacementText: in your delegate object:

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

    Note that if the user pastes in text containing a newline and other characters, this will not catch the newline. It will only notice when the user either taps the Return key, or when he pastes in text containing just a newline.

    You can declare the delegate’s class as conforming to the UITextViewDelegate protocol, in which case Xcode will helpfully autocomplete the method name. But it will work even if the class doesn’t conform to the protocol.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading a description about swapping pointer addresses on Stackoverflow, I have a question
I've been reading about (N)RVO and would like one, complete scenario description. I hope
Reading documentation about fileReader , and find out that they write methods using void
I was reading about AsyncTask and I tried a program. But it does not
I know that questions about XML had been answered million times here but i
I'm reading the book about optimization teckniks. There is not much description or advices
I am reading about logging using java and came across this: enter link description
I am reading the IEEE Standard Verilog Hardware Description Language (specifically IEEE Std 1364-2001)
I was reading thourg this example (link) ... From the description, this seems paradox
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.