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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:41:51+00:00 2026-05-26T22:41:51+00:00

I am using two view controllers. On button action of first view controller i

  • 0

I am using two view controllers. On button action of first view controller i am adding the second view controller’sview as subview to the first view controller. I am not able to release the second view controller so i am getting memory leak for the secondviewcontroller object. How to release the second view controller object after adding it as subview?

 -(IBAction)buttonclick {
    secondviewcontroller * obj = [[secondviewcontroller alloc]init];
    [self.view addsubview:obj.view];
   [obj release]; //if i release it here the view is also getting released and only black screen is displayed.how to release the second view controller obj after this?
    }

sorry that was typing mistake earlier

  • 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-26T22:41:52+00:00Added an answer on May 26, 2026 at 10:41 pm

    You really shouldn’t be doing this.

    In iPhone apps you should always present a single view controller for each screen.
    I would suggest moving any logic you have in the second view controller into the backing class of the view you are adding.

    If you’re dead set on having two view controllers, then hold a reference to the second view controller in the first view controller (retained) and release the second view controller whenever the second view is removed from its super view (and in the dealloc of the first view controller).

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

Sidebar

Related Questions

I have two view controllers, in which I am using navigation controller to navigate
I have a view that has two buttons(First and Second) and one hidden field.
I'm using the following code in two view controllers; one, where it is triggered
How do I go about having two view models communicate with one another using
I have created an alert view with two buttons using the following code: UIAlertView
I'm using MVC2 with VS2010 I have a view that has two partial views
I have two text fields in my view. I did it using IB. My
I'm currently re-using a partial on two different views. View A View B The
I currently am using two stylesheets to get my intended output. The first stylesheet
My controller action is being executed twice. Fiddler shows two requests and responses, and

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.