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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:55:49+00:00 2026-05-24T06:55:49+00:00

So I want a RootViewController that can handle a different view controller for each

  • 0

So I want a RootViewController that can handle a different view controller for each cell (Okay, I have my reasons not to reuse nibs here).

I can list them all up in the didSelectRowAtIndexPath like this:

if(condition){
   DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" 
                                                                                    bundle:[NSBundle mainBundle]];
        dvController.selectedCountry = selectedCountry;
        [self.navigationController pushViewController:dvController animated:YES];

        [dvController release];
}

else if (condition2){        
        DetailViewController2 *dvController2 = [[DetailViewController2 alloc] initWithNibName:@"DetailViewController2" 
                                                                                    bundle:[NSBundle mainBundle]];
        dvController2.selectedCountry = selectedCountry;
        [self.navigationController pushViewController:dvController2 animated:YES];

        [dvController2 release];
        dvController2 = nil;
}

but that can be quite long and I don’t know any other way to do it. Are there some sort of “special controllers” or classes that I can use to address this? I am new to iOS development so I know just a little of it.

Thanks in advance!

  • 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-24T06:55:49+00:00Added an answer on May 24, 2026 at 6:55 am

    I think you can use a Factory Method returning an object of UIViewController as that is the argument type of pushViewController (as you can see in the API docs for UINavigationController). Basically you create a method expecting an int,String,Enum to tell what kind of DetailView you want to create, then it creates an object of the given DetailView implementation and returns it. Then you can push that new controller using pushViewController.

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

Sidebar

Related Questions

I have a view controller that I want to be released (and then possibly
I have an iphone app that uses table view as the interface. Each time
I have a XIB (RootViewController) that has actions I want to do from a
want to have a Hyperlink-Button in a gridView in which I can display a
I have a view based project working with a UINavigationController. The RootViewController performs operations
So I have a UINavigationController that pushes a UITableViewController from the rootViewController. From the
I have a RootViewController, and multiple ViewControllers that branch out from the same when
So, I push a view controller from RootViewController like: [self.navigationController pushViewController:anotherViewController animated:YES] ; BUT,
I have made a Tabbar based application in that i have three tab. each
I have a UITableViewController, which is RootViewController. It's XIB only has a table view.

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.