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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:20:52+00:00 2026-06-01T21:20:52+00:00

I need to free the view of my mainViewController I have on a navigationViewController

  • 0

I need to free the view of my mainViewController I have on a navigationViewController in order to avoid the memory-warnings that I’ve been receiving.

The good practice loading the view is in the ‘loadview’ method, but when I try to dealloc the view (when I go to the next controller of the stack) doing “self.view = nil” it calls again the ‘loadview’ method so nothing happens.

I solved this problem loading the view in the ‘viewWillAppear’ method, but, my question is:

Is that procedure correct?
If not (that’s what I think) how can I release that view to free its memory?

Which is the best (or more correct) way to do it?

This is the code:

‘loadView’ without loading the view

- (void)loadView
{
    [super loadView];
    (some more code)
}

The view it is loaded here

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (!pral)
    {
        pral = [[TouchDrawView alloc] initWithFrame:[UIScreen mainScreen].bounds];
           [self setView:pral];
           [pral release];
    }
        (some more code)
}

This is the call to the next viewController of the stack

- (void)menus:(id)sender
{
    opcions *ops = [[opcions alloc] init];
    [[self navigationController] pushViewController:ops animated:YES];
    [ops release];

//Here I'm trying to free memory releasing the view
    [pral removeFromSuperview];
    pral = nil;
    self.view = nil;
}

Thanks

  • 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-01T21:20:54+00:00Added an answer on June 1, 2026 at 9:20 pm

    A better hook to build custom subviews is viewDidLoad.

    Minimally, you should free the retained subviews (pre-ARC) in didReceiveMemoryWarning and in dealloc.

    No need to release when you push to the new viewController. Your old one is still there, underneath.

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

Sidebar

Related Questions

I have been searching around for free or commercial AR toolkits and need some
I am developing an OPC client and need a free OPC server that can
Related to https://stackoverflow.com/questions/139944/where-can-one-find-free-software-icons-images I have a need for free weather-related icons. Specifically, I need
I need recommendations for a good (free) development notepad to work in on my
I need to do some reports that aren't strictly a listing-of-entities. More free-form query,
At various points during my application's workflow, I need so show a view. That
I need to create a view or a table valued function that returns one
So I've been working on a project that requires offering the possibility to view
Basically, I want to have an app with only one view that has an
I have a view that displays a group of featured nodes of different categories

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.