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

Related Questions

I have an application that has many views (Using tab bar controller). I want
Hello I am using a tab bar application. I want to reload a view
I need to change tab icon if selected or not. I am using following
I have setup tab bar controller using interface builder, and each tab bar item
NOT USING A XML PARSER I want to get the contents of the XML
Okay so I'm not using any session variables, rather my code looks like this:
I'm trying to get a tab bar effect not unlike Russell Quinn's Creative Review
In my application I'm using a Navigation Controller to push one view that loads
I have been able to disable tabs in a tab bar using the following
I have a Tab Bar with a navigation table view. My app crashes when

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.