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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:31:05+00:00 2026-05-30T14:31:05+00:00

I am trying to load view that contains a map view and 2 buttons,

  • 0

I am trying to load view that contains a map view and 2 buttons, from inside a separate NOB file.

EDIT: I should have mentioned that I must not subclass a UIViewController, because I don’t want the view to be presented the standard way (as a modal for example). I want it to use only a quarter of the screen, be transparent, and be presented like a popup view. Therefore, UIVIewController is NOT advisable for a view that won’t take up the entire screen or at least won’t be presented as a standard modal view controller or a controller of a UINavigationController hierarchy.

Not wanting to use a UIViewController subclass (Apple says to not do that), I decided to build a ContainerObject, descendant of NSObject, that will handle the connections and deallocations.

Inside the container object I only have 1 IBOutlet: (the view). I load the nib this way inside the init function:

- (id)init {
self = [super init];
if (self) {
    [[NSBundle mainBundle] loadNibNamed:"myNib" owner:self options:nil];
}
return self;

}

Inside the NIB there is a view, that has a MapView inside it, and two buttons. As the file’s owner I have set the class of my Container object, and the I have connected the “view” outlet to the outlet in the file’s owner. The nib load fine, and I am able to load it and add its view to my subview.

self.currentLocationMapView = [[[CurrentLocationViewContainer alloc] init] autorelease];
self.currentLocationMapView.delegate = self;
[self.view addSubview:self.currentLocationMapView.view];

The problem lies in the deallocation, because while the container object is successfully deallocated, the view is NOT deallocated inside it:

    [self.currentLocationMapView.view removeFromSuperview];
self.currentLocationMapView = nil;

The dealloc message of my custom view, which lies in the container object is never called. I must explicitly call [self.currentLocationMapView.view release] in order to have it deallocated when I want it to.

Note that “self.currentLocationMapView.view” is the container object in my view controller. The container object holds the custom view, which in turn holds the map view and the 2 buttons.

  • 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-30T14:31:06+00:00Added an answer on May 30, 2026 at 2:31 pm

    Since no one answered the question, I may as well answer it myself, since I found the solution, and some other useful information while searching for it.

    The solution to my problem lied into a very difficult to find bug in my application. It doesn’t matter what the bug was, it is very application-specific and unlike to happen in any other app.

    As far as UIViewControllers are concerned, you should not use UIViewControllers or subclasses to present Views with method other that the Apple’s Standard methods. Ever. If you want to present a view to the user which is not part of a view hierarchy like a UITabBarController, or UINavigationController or anything like that, you must do so programmatically without using a View Controller as a manager object of this class. You should use NSObject as the manager of the view instead.

    This is because UIViewController’s internals keep references to views and other objects inside them, that are released when certain methods of the UIViewController are called. When not part of an Apple view hierarchy, these methods will never get called, thus creating memory leaks.

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

Sidebar

Related Questions

I'm trying to load a page that is basically an edit form inside a
I'm trying to load some data from a plist file. It contains an NSArray
I am am trying to load a SQL table from a flat file. The
I'm trying to load a view controller from a nib in Interface Builder. My
I'm trying to load in my WebView some HTML code that contains JavaScript. Now
I'm trying to create a nib that contains a view that will be embedded
I am currently trying to load my custom table view cell from its own
I have created a view that contains a CGGradient: // Bar ContextRef CGRect bar
I have a view that contains a DocumentViewer control and I have another class
I am working on an app where i have a view controller that contains

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.