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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:11:14+00:00 2026-06-13T10:11:14+00:00

I have a main view, mainWindow, which presents a couple of buttons. Both buttons

  • 0

I have a main view, mainWindow, which presents a couple of buttons. Both buttons create a new UIViewController (mapViewController), but one will start a game and the other will resume it. Both buttons are linked via StoryBoard to the same View. They are segued to modal views as I’m not using the NavigationController.

So in a typical game, if a person starts a game, but then goes back to the main menu, he triggers:

[self dismissViewControllerAnimated:YES completion:nil ];

to return to the main menu. I would assume the view controller is released at this point.

The user resumes the game with the second button by opening another instance of mapViewController. What is happening, tho, is some touch events will trigger methods on the original instance (and write status updates to them – therefore invisible to the current view). When I put a breakpoint in the mapViewController code, I can see the instance will be one or the other (one of which should be released).

I have tried putting a delegate to the mainWindow clearing the view:

    [self.delegate clearMapView];

where in the mainWindow

- (void) clearMapView{
    gameWindow = nil;
}

I have also tried

self.view=nil;

in the mapViewController.

The mapViewController code contains MVC code, where the model is static. I wonder if this may prevent ARC from releasing the view.

The model.m contains:

static CanShieldModel *sharedInstance;

+ (CanShieldModel *) sharedModel
{
@synchronized(self)
{
    if (!sharedInstance)
        sharedInstance = [[CanShieldModel alloc] init];     
    return sharedInstance;
}
return sharedInstance;
}

Another post which may have a lead, but so far not successful, is UIViewController not being released when popped

I have in ViewDidLoad:

    // checks to see if app goes inactive - saves.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive) name:UIApplicationWillResignActiveNotification object:nil];

with the corresponding in ViewDidUnload:

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];

Does anyone have any suggestions?

EDIT:

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSString *identifier = segue.identifier;

if ([identifier isEqualToString: @"Start Game"]){
    gameWindow = (ViewController *)[segue destinationViewController];
    gameWindow.newgame=-1;
    gameWindow.delegate = self;

} else if ([identifier isEqualToString: @"Resume Game"]){
    gameWindow = (ViewController *)[segue destinationViewController];
    gameWindow.newgame=0;
    gameWindow.delegate = self;
  • 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-13T10:11:16+00:00Added an answer on June 13, 2026 at 10:11 am

    My theory is that something is holding a strong reference to your UIViewController.

    From the segue code you posted above, it looks like you are keeping a reference gameWindow to the modal view controller. If this is the case, then you’ll want to add __weak in front of it’s declaration so that it isn’t holding on to your mapViewController when you dismiss it.

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

Sidebar

Related Questions

I have 2 views (first view - custom user control, MainWindow view - main
I have a main view to which I have added a subview using the
I have an application composed of a main view and a secondary view which
I have a main window which hosts two views (user controls). One is UserControl1
I have a main view controller that consists of 1 button that when tapped,
In my Backbone application I have a main view that shows previews of posts.
I'm developing an iOS 4 application. I have a main view that contains another
I'm trying to write my first simple mvc app. I have a Main View
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
I have a window with a main view of type NSView and a subview

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.