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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:52:35+00:00 2026-05-31T13:52:35+00:00

Every time I show some subView with this code, clearImage creates every time, and

  • 0

Every time I show some subView with this code, clearImage creates every time, and after 10 executions there are 10 images!
How to delete this image after removeFromSuperview?

- (IBAction)nextTutorial:(id)sender {
    UIImageView *clearImage = [[UIImageView alloc] initWithFrame:CGRectMake(270, 0, 50, 50)];
    clearImage.image = [UIImage imageNamed:[settings objectAtIndex:7]];

    UIImageView *helpImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    helpImage.image = [UIImage imageNamed:[settings objectAtIndex:8]];

    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(60, 7, 200, 30)];
    slider.value = 0.5;

    if (hintnumber == 1) {
        self.hintLabel.text = [settings objectAtIndex:1];
        [self.view addSubview:slider];
        hintnumber = 2;
    } else if (hintnumber == 2) {
        self.hintLabel.text = [settings objectAtIndex:2];
        [self.view addSubview:clearImage];
        hintnumber = 3;
    } else if (hintnumber == 3) {
        self.hintLabel.text = [settings objectAtIndex:3];
        [self.view addSubview:helpImage];
        [self.nextButton setTitle:[settings objectAtIndex:5] forState:UIControlStateNormal];
        hintnumber = 4;
    } else if (hintnumber == 4) {
        hintnumber = 1;
        [slider removeFromSuperview];
        [clearImage removeFromSuperview];
        [helpImage removeFromSuperview];
        slider = nil;
        clearImage = nil;
        helpImage = nil;

        [self.view removeFromSuperview];
    }
  • 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-31T13:52:36+00:00Added an answer on May 31, 2026 at 1:52 pm

    UPDATE based on new code:

    If hintNumber is 4, you are creating an object, never adding it to a view, and then removing it from a view that it isn’t in. You need to remove the object that was added previously from it’s superview, and not the one that you just created using something like [[self.view viewWithTag:99] removeFromSuperview]; and set the tag number of clearView to 99 when you create it.

    As an aside, you should only create the new objects when you need them.

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

Sidebar

Related Questions

Every time i delete or destroy a Product it aways give me this error
So the transparent background problem is solved. Now, every time I show the form
Every time I call this method my NSMutableData is leaking and I cannot figure
I'm getting this every time I attempt to debug my app in the simulator:
I am developing an application where I need to update some info every time
Possible Duplicate: Xcode 4.2 jumps to main.m every time after stopping simulator Whatever a
I need to perform an ajax request to send some data server-side every time
Every time I've joined a new company I've found that there is an in-house
Hi I write some code to hide and show some based on the selected
Every time I turn on my company-owned development machine, I have to kill 10+

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.