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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:04:45+00:00 2026-05-20T01:04:45+00:00

I have 5 different views and when I tap the button, I want to

  • 0

I have 5 different views and when I tap the button, I want to push one of 5 views randomly. However, I do not want to make 5 different controllers for each views. Do I have a chance to put them in one controller? If so, how?

  • 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-20T01:04:45+00:00Added an answer on May 20, 2026 at 1:04 am

    You can have as many views as you want in a single UIViewController subclass. You can create them all in Interface Builder as well, in the one .xib file for your UIViewController class (it might get a bit hard to see, though, better to lay out each UIView in its own .xib). You can present them in any combination you want. Assuming you want to just show one view at a time, you can do this:

    In your viewDidLoad method, start out showing the initial view, and in your class keep track of which is the current view:

    ...
    @property(nonatomic, retain) UIView *currentView;
    ...
    - (void)viewDidLoad 
    {
        [self.view addSubview:self.defaultView];
        self.currentView = self.defaultView;
    }
    
    Then to switch to a particular other view do this:
    
    - (void) switchToView:(UIView *)newView
    {
        [self.currentView removeFromSuperView];
        [self.view addSubview:newView];
        self.currentView = newView;
    }
    
    
    }
    

    Or you can show them all at one time: just [self.view addSubview:theView];

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

Sidebar

Related Questions

I've got a table recording views of programs. Each program can have two different
We want to create a screen which should have different list views and the
I have a UITabBarController , if I push to different views from the first
I have to do some different views containing 72 LED lights. I built an
I have a UITabBarController with two different views to switch between. What I would
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have an if/else statement in the controller and 2 different types of views
I am implementing view controllers that shall have different behaviour. They have a common
I have an application containing a variety of view controllers linked together in different
I would like to have different views of a webpage depending on certain attributes

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.