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

  • SEARCH
  • Home
  • 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 8333673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:06:43+00:00 2026-06-09T03:06:43+00:00

I am trying to get delegate methods to work with UITextView, but it’s not

  • 0

I am trying to get delegate methods to work with UITextView, but it’s not working for some reason.

I have declared in my viewController.h that it is a UITextViewDelegate

I am trying to get the following code to work to erase the default code “TEXT” when I tap on the textView.

- (void)textViewDidBeginEditing:(UITextView *)textView {

    if (myTextView.text == @"TEXT") {
        [myTextView setText:@""];
    }

    NSLog(@"did begin editing");
}

I expected to the text to be cleared and to see the NSLog print when I tap on the textView and the keyboard appears. Nothing at all happens


Using a text view by the way because I need to scale the view based on its content size and seems that the textView has a contentSize property, whit label and textField do not.

UPDATE:

I should have used:

if ([myTextView.text isEqualToString:@"TEXT"]) {
    [myTextView setText:@""]; }

here is the project if you want to take a look.

  • 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-09T03:06:46+00:00Added an answer on June 9, 2026 at 3:06 am

    this method is missing from your Test2ViewController.m file:

    - (void)viewDidLoad {
        [myTextView setDelegate:self];
    }
    

    or you can connect the delegate in the Interface Builder as well, if you prefer that way better.

    UPDATE #1:

    add this method to you class for controlling the return key.

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
        if ([text isEqualToString:@"\n"]) {
            NSLog(@"Return pressed, do whatever you like here");
            return NO; // or true, whetever you's like
        }
    
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying get Struts 2 and Tiles to work and I am using
Trying to get this expression to work, can someone look at it and tell
I have been trying to write a delegate to a view controller which has
I have an object DataParameterInfo (DPI) with a couple of delegate methods that are
I've been trying to get this to work for a while now. I've done
I have been trying for the last few hours to get a UIAlert with
I'm trying to get the jstree plugin working, following the Predefined HTML example on
I'm trying to get this to work. $.fn.createDelegate = function(scope){ var fn = this;
UPDATE: Tried the links you suggested, but can't get it to work. Just to
Why does this not work? What I am trying to do: I need a

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.