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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:09:36+00:00 2026-05-26T18:09:36+00:00

I have a small UIView that I hide/show in to show a message to

  • 0

I have a small UIView that I hide/show in to show a message to the user. The message itself is in a UITextView that I add to the small UIView that gets shown.

The sliding-in and sliding-out works fine – but the prior messages are not cleared. I have spent enough time to fix the problem – but to no avail. Can someone lend me their eyes!!

enter image description here

Here is how the UITextField is created programatically:

@interface MessageVC : UIViewController {
    UITextView    *messageTV;
}
@property (nonatomic, retain) UITextView    *messageTV;

- (id)init;
- (void)showMsg:(NSString *)title;
@end

and

- (id)init {
  if (self = [super init]) {      
      self.view = [[[UIView alloc] initWithFrame:CGRectMake(0, 380, 320, 100)] autorelease];
      [self.view setBackgroundColor:[UIColor blackColor]];
  }
  return self;
}


- (void)showMsg:(NSString *)title {
    [self setMessageTV : [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 315, 90 )]];
    [[self messageTV] setBackgroundColor : [UIColor greenColor]];
    [[self messageTV] setTextColor : [UIColor whiteColor]];
    [[self messageTV] setText:@""];                            <<<<<<<< - does not clear the text
    [[self messageTV] setText : title];

    [self.view addSubview : [self messageTV]];
    [self.view setHidden:NO];
}

- (void) hideMessage {
    [self.view setHidden:YES]
}
  • 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-05-26T18:09:37+00:00Added an answer on May 26, 2026 at 6:09 pm

    I’ll go out on a limb and ask why you’re using a UITextView. I honestly have never needed to use a UITextView. Try changing it to a UILabel and see if the problem is specific to the UITextView. If you absolutely need a UITextView, let me know in a comment, but I have a suspicion that a UILabel is what you’re after.

    It appears that you are adding it as a subview every time. So you’re actually creating multiple UITextViews and adding them on top of each other. You would either need to removeFromSuperview or just set the text of the instance variable.

    Take these two lines out of showMsg and put them in viewDidLoad:

    [self setMessageTV : [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 315, 90 )]];
    [self.view addSubview : [self messageTV]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small UIView that displays a repeated movie. When the user taps
I have a small UIView that should appear always in the center of the
I have this function that taking a screenshot of the a small UIView that
I have an app with a small uiimageview circle that fades in and out
I have a class called GraphView that extends UIView that basically draws a small
I have a small floating UIView, viewHover, which acts as a container to 2
I have small web app that generate PDF files as a report. I'm trying
I have a xib-file with a small UIView on it, which in turn contains
Good day all; I have an UIImageView that I animate around a large UIView.
I have 2 methods that add the Previous, Next & Done toolbar above the

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.