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 7762293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:21:45+00:00 2026-06-01T14:21:45+00:00

I have researched how to manually include a PlaceHolder Text in UITextView (as there

  • 0

I have researched how to manually include a PlaceHolder Text in UITextView (as there are many on StackOverflow), however, whenever I click on the TextView and start typing, it does not erase the placeholder, and I am not sure why. Any help is appreciated! Thanks!

#import "HusbandryAddRecord.h"
#import <QuartzCore/QuartzCore.h>

@interface HusbandryAddRecord()

@end

@implementation HusbandryAddRecord

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [scroller setScrollEnabled:YES];
    [scroller setContentSize:CGSizeMake(320, 601)];

    // Round The Corners of the Notes TextView
    notesTV.clipsToBounds = YES;
    notesTV.layer.cornerRadius = 10.0f;

    placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, notesTV.frame.size.width - 20.0, 34.0)];
    [placeholderLabel setText:@"Notes"];
    [placeholderLabel setBackgroundColor:[UIColor clearColor]];
    [placeholderLabel setFont:[UIFont fontWithName:@"System" size:14.0]];
    [placeholderLabel setTextColor:[UIColor lightGrayColor]];

    [notesTV addSubview:placeholderLabel];
}

- (void)viewDidUnload
{
    [notesTV release];
    notesTV = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [notesTV release];
    [super dealloc];
}

- (void) textViewDidChange:(UITextView *)theTextView {
    if(![theTextView hasText]) {
        [theTextView addSubview:placeholderLabel];
        [placeholderLabel setText:@"Notes"];
    }

     else if ([[theTextView subviews] containsObject:placeholderLabel]) {
        [placeholderLabel removeFromSuperview];
    }
}

- (void)textViewDidEndEditing:(UITextView *)theTextView {
    if (![theTextView hasText]) {
        [theTextView addSubview:placeholderLabel];
    }
}

@end
  • 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-01T14:21:47+00:00Added an answer on June 1, 2026 at 2:21 pm

    Whats really happening is you are adding the label to your textview for each inputing characters. So there are as many labels created one after above if you type characters and when the condition meets you remove only one label and the below lying labels are visible.

    Make sure you have the delegate set properly and then use the hidden property instead of adding and removing subviews.

    - (void)textViewDidChange:(UITextView *)textView
    {
        placeholderLabel.hidden = textView.hasText;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows Forms and Navigation I have researched and read many different web articles and
I have researched this topic for months now with no success. Many posts say
I have researched this to death. There does seem to be some answers here
I have researched this for a few hours and I am kind of frustrated.
I have researched enough on this topic sans any luck :-( My requirement is
I have researched and researched and I am trying to use jquery to refresh
I have researched a lot about creating my own app for android with a
I researched over the internet, but could not find anything... I have a mysql
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have about four web projects that I am hosting in IIS Express. Whenever

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.