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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:40:43+00:00 2026-05-11T14:40:43+00:00

I am not using a tab bar or any other control — I want

  • 0

I am not using a tab bar or any other control — I want to basically change the current view to a different view controller dynamically (i.e. via code). I’m not using Interface Builder at all…

For example, let’s say we create three view controllers:

(this may not be the best example, but I’m trying to make it simplistic)

View_Hello.m (and .h)

View_Goodbye.m (and .h)

View_Ciao.m (and .h)

Our ViewerAppDelegate would launch View01_Hello.

View_Hello would have a custom touch method that would then need to go to View_Ciao if swiped, but View_Goodbye if just touched.

Any ideas on how I could do this (and please don’t say ‘oh, you need to use xxx interface element for this example’. I need to be able to randomly change views based on programatic control within the view of the application I’m working on)

I’m been surfing through Google and StackOverflow for the past week, and gone through my three O’Reilly Cocoa books (plus three iPhone developer books), and all of them just use simple interfaces — but nothing shows an example like what I’m trying to do.

===========

Edit (@Andrew Grant):

for example:

View_Ciao *viewCiao;  -(void) viewDidLoad {    viewCiao = [[View_Ciao alloc] initWithNibName:@'View_Ciao' bundle:nil];   [viewCiao.view setNeedsDisplay];   [super viewDidLoad]; } 

This crashes. 🙂

=============

Edit (@Daniel Dickison)

Brilliant — that worked!

- (void)applicationDidFinishLaunching:(UIApplication *)application {          [window addSubview:viewController.view];     [window makeKeyAndVisible];      // create the second view, remove the first, and then display the second      viewCiao = [[ViewCiao alloc] init];     [viewController.view removeFromSuperview];        [window addSubview:viewCiao.view]; } 
  • 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. 2026-05-11T14:40:43+00:00Added an answer on May 11, 2026 at 2:40 pm

    How about something like:

    @interface AppDelegate : ... {     View_Hello *hello;     View_Goodbye *goodbye;     View_Ciao *ciao;     UIViewController *currentView;     UIWindow *window; } ... IBOutlet properties for the 3 controllers. @end  @implementation AppDelegate - (void)switchToGoodbye {     [currentView.view removeFromSuperview];     [window addSubview:goodbye.view];     currentView = goodbye; } ... etc. @end 

    You may need to resize the view before adding it to the window, and call viewWillDisappear:, viewDidDisappear:, viewWillAppear: and viewDidAppear: on currentView and the new view controller before and after they’re removed/added.

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

Sidebar

Ask A Question

Stats

  • Questions 249k
  • Answers 249k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can cache your images using a pool of SoftReferences… May 13, 2026 at 9:11 am
  • Editorial Team
    Editorial Team added an answer It is possible, but you will not see anything in… May 13, 2026 at 9:11 am
  • Editorial Team
    Editorial Team added an answer UITabBarController handles this completely automatically. If you add more than… May 13, 2026 at 9:11 am

Related Questions

I am not using a tab bar or any other control -- I want
My app has a main screen that the user always starts at, and from
I have an app that has a tabBar Controller and a navBar Controller. It
As a new Eclipse user, I am constantly annoyed by how long it takes
I have an UITabBar controller managing several controllers (using SDK 3.0). One of these

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.