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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:18:51+00:00 2026-05-13T15:18:51+00:00

I’m creating some UILabels in my UIView , filling them with data, adding them

  • 0

I’m creating some UILabels in my UIView, filling them with data, adding them to view, and releasing them.

 UILabel *speed = [self scrollLabel:@"some Text" x:455.0f y:75.0f];
 [scrollView addSubview:speed];
 [speed release];

The method:

- (UILabel *)scrollLabel:(NSString *)text x:(float)x_ y:(float)y_ {

 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x_, y_, 300.0f, 20.0f)];
 [label setText:NSLocalizedString(text,@"")];
 [label setFont:[UIFont fontWithName:@"Helvetica" size:14]];
 [label setTextColor:[UIColor colorWithRed:255.0 green:255.0 blue:255.0 alpha:1.9]];
 [label setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]];

 return label;

}

I got a button, where the user can reload the data of the uilabels. I’m removing the parent view of all these labels from superfiew, generating the new data and doing the method where the labels are set, again.

The problem is, the old UILabels are still existing, so my question is, whats the best way to remove this special labels?

I made a loop and removed all subviews, the problem is, I also got some other subviews in there, which I don’t want to delete.

Another question: Is there a better way to setup font-styles for multiple Labels?

  • 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-13T15:18:51+00:00Added an answer on May 13, 2026 at 3:18 pm

    I would suggest adding all the labels in a specific UIView, let’s call it labelHolderView. Then every time you want to remove them, just iterate through all of its children and call removeFromSuperview for each one.

    If you only want to remove specific UILabels, please provide more info as to which ones they should be.

    One thing I would suggest for your code above: your - (UILabel *)scrollLabel:(NSString *)text x:(float)x_ y:(float)y_ method should return an autoreleased UILabel. So its last line should be return [label autorelease];. If you want to return a retained object, add new/copy/retain in the method’s name, so that you know that the returned object is being retained every time you call it.

    Consequently, you don’t need to release the label after you add it to the UIView. This does not affect your specific program, but it’s good to get in the habit of doing it this way so that you don’t mess your retains/releases in the future.

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

Sidebar

Related Questions

No related questions found

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.