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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:07:56+00:00 2026-06-01T07:07:56+00:00

In my iPhone/iPad app, I am adding one subview to my main view. This

  • 0

In my iPhone/iPad app,

I am adding one subview to my main view.

This subview has one imageview and button.

When to release them ?

My code is here,

 customAlertView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 600, 600)];


         UIImageView *imgv=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"celebration.png"]];

          UIButton *btnOK=[UIButton buttonWithType:UIButtonTypeCustom];

         [btnOK setTitle:@"OK" forState:UIControlStateNormal];
         [btnOK addTarget:self action:@selector(alertOKClicked) forControlEvents:UIControlEventTouchUpInside];

         [customAlertView addSubview:btnOK];
         [customAlertView addSubview:imgv];
         [self.view addSubview:customAlertView];

         [imgv release];
         [btnOK release];



In one another method I am writing the code.

  [customAlertView removeFromSuperview];

My confusion is imageview and button is there If

  1. I release the customalertview here will it releases its subviews automatically.
    If yes then no problem.
  2. If NO how to release it

    as I have done here released the objects immediately after adding subviews.
    It will cause my OK button Unworthy. And will not affect the button click.

    So, On removing from superview should I write.

[[customalertview subviews] release];

  • 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-01T07:07:58+00:00Added an answer on June 1, 2026 at 7:07 am

    Your code is correct.

    You release them after you’ve added them to the alert view, as the alert view takes care of retaining them. When you call removeFromSuperview, it’ll get released automatically.

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

Sidebar

Related Questions

If I'm creating a universal iPhone/iPad app, I have two XIBs. One main XIB
I'm designing an iPad/iPhone app using core data. The main focus of the app
I have an app which has different app identifier for iphone and ipad and
Possible Duplicate: iPhone/iPad App Code Obfuscation - Is it Possible? Worth it? I have
I was recently asked if I could code a simple IPhone/IPad app that: Checks
The iPhone/iPad app 'Things' has a registered URI scheme. I know it exists: things://
I'm porting a fairly simple iPhone Navigation based app to a Split View iPad
I have a universal iPhone/iPad app. On the main menu I have a UIImage
I am intending to build an iPhone/iPad app that has a feature allowing users
I have a Universal app (iPhone/iPad) which has an iAd displayed at the bottom

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.