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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:50:02+00:00 2026-06-10T01:50:02+00:00

I am a novice programmer for the iPhone. In developing my first game/app, I

  • 0

I am a novice programmer for the iPhone. In developing my first game/app, I have come up with a problem (created a problem) for myself. I have researched this and think I have seen answers but I don’t understand how to make them work for my application.

I have a game that has a few view controllers: Welcome, Play, High Scores, Preferences and About. I don’t have a navigation controller or a root controller of which I am aware. EDIT – I now have a rootview controller – I added [self.window setRootViewController:viewController]; to my appDelegate.m file

From the Welcome screen/viewcontroller I can go to the Play view controller, the about view controller, the high scores view controller or the prefs view controller. I would like to make whichever new controller I go to now be in charge, so that I can dismiss the Welcome view controller. In fact, any time I go to a view controller, I would like to be able to dismiss from memory any of the other view controllers – especially the one I just came from. I can go to most of the viewcontrollers from most of the viewcontrollers.

I go to the new view controllers using this:

- (IBAction)playGameAction:(id)sender {
    FlipTestViewController *myViewController = [[FlipTestViewController alloc]

   initWithNibName:@"FlipTestViewController" bundle:nil];

    [UIView beginAnimations:@"flipview" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                           forView:self.view cache:YES];

    [self.view addSubview:myViewController.view];

    [UIView commitAnimations];
}

What do I do to let the WeclomeViewController go, once I am safely in the FlipTestViewController (the play controller)? And how do I tell the new controller that it is now in charge and the others can go away? Am I even asking a question that makes sense? Please use small words and concrete examples when responding! Thank you!

On rdelmar’s advice, I tried adding a call to change the RootvVewController into my button code – the code I use to bring up the new viewController:

- (IBAction)playGameAction:(id)sender {
    FlipTestViewController *myViewController = [[FlipTestViewController alloc]
                                                      initWithNibName:@"FlipTestViewController"
                                                      bundle:nil];

    [UIApplication sharedApplication].delegate.window.rootViewController = myViewController;
    [UIView beginAnimations:@"flipview" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                           forView:self.view cache:YES];

    [self.view addSubview:myViewController.view];

    [UIView commitAnimations];

}

Sure enough, then I look in the comments, the FlipTestViewController (my Play Controller) is the new RootViewController. Unfortunately, I get a blank white screen, no transition of any kind and log message telling me that my ViewDidDisappear in my FlipTestViewController is being called somehow. Probably because the Welcome Screen is still there somehow. Memory management problem perhaps? Ought I to take this to a new question?

I just changed the background color of the main.xib file and apparently that is the screen that is showing up (the blank white screen).

  • 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-10T01:50:04+00:00Added an answer on June 10, 2026 at 1:50 am

    It sounds like the easiest way to achieve what you want is to just reset the rootViewController property of the app’s window. From anywhere in the app you can get a reference to the root view controller with [UIApplication sharedApplication].delegate.window.rootViewController. So, in whatever action method you’re using to switch to the next view controller, you could alloc init that controller and then set the window’s rootViewController property to that controller. If you keep no other reference to a controller, the old one should be deallocated when you reset the property (which may or may not be what you want — you might want to have some properties that would keep track of the high score or where the player was in a game, for instance).

    In the app delegate there is usually code something like this (when you start with a single view project):

     WelcomeController *welcome = [[WelcomeController alloc] initWithNibName:@"ViewController" bundle:nil];
     self.window.rootViewController = welcome;
    

    So I would put something like that in your app delegate with whatever view controller you want to show at start up. Then in your view controller code (or wherever your putting your buttons to switch view controllers) you would have something similar to (I used a segmented control in my test project):

    -(IBAction)selectController:(UISegmentedControl *)sender {
        if (sender.selectedSegmentIndex == 0) {
            PlayViewController *player = [[PlayViewController alloc] initWithNibName:@"PlayViewController" bundle:nil];
            [UIApplication sharedApplication].delegate.window.rootViewController = player;
        }else{
            HighScores *scorer = [[HighScores alloc] initWithNibName:@"HighScores" bundle:nil];
            [UIApplication sharedApplication].delegate.window.rootViewController = scorer;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Novice programmer asking first question on stack-overflow. I am writing an app for mac
I'm a crappy novice programmer and have been struggling to get this working for
I'm a novice programmer. This may be a simple problem but I've never seen
I am a novice WPF programmer. My problem is as below. I have a
I'm a novice php programmer and having a problem assembling this code to work.
I'm a novice programmer and I'm trying to learn Android coding using Eclipse. This
I'll admit I'm a novice programmer and really the only experience I have is
So I would call myself a fairly novice programmer as I focused mostly on
I'm a novice Javascript programmer, so I apologize if this question makes no sense.
(I'm a complete novice programmer) I recently came across a problem with my custom

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.