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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:10:33+00:00 2026-06-01T15:10:33+00:00

I’m trying to get a GUI with a UITabBar and UITableViews set up. I’ve

  • 0

I’m trying to get a GUI with a UITabBar and UITableViews set up.

I’ve got a UITabView that is programmatically created.
One of the Tabs displays a UITableView that is also programmatically created.

This UITableView then displays other views when didSelectRowAtIndexPath is called.

Unfortunately, when a table cell is clicked, my tab view goes away and the new table view is displayed.

What I can’t get my head around is how to structure the views so that the tabBar stays on the screen.

Is it as simple as making the UITableViews shorter, or is there some window/view mojo that I’m missing?

Thanks

  • 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-01T15:10:34+00:00Added an answer on June 1, 2026 at 3:10 pm

    You should use a UITabBarController to display the UITabBar rather than doing it directly.

    Then use a UITableViewController as the view controller for a given tab. Though I get the impression that you want to present descendent UITableViews when a row is selected. If this is the case, you ought to use a UINavigationController as the tab bar’s view controller, and let it manage your UITableViewControllers.

    Remember that on iOS you really need to use the view controller pattern – the frameworks take care of a lot of things for you under the hood.


    Follow-up:

    OK, the following straightforward implementation works just fine for me. Please ignore the many obvious issues with this code (beginning with the fact that I hacked it all together in the application delegate!); it’s intended purely as a model for how your controllers should be glued together.

    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate, UITableViewDelegate, UITableViewDataSource>
    
    @property (strong, nonatomic) UIWindow *window;
    @property (strong, nonatomic) UINavigationController *navController;
    
    @end
    
    
    
    
    @implementation AppDelegate
    
    @synthesize window = _window;
    @synthesize navController = _navController;
    
    - (void)dealloc
    {
        [_navController release];
        [_window release];
        [super dealloc];
    }
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    
        UITableViewController *rootTVC = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
        [[rootTVC tableView] setDelegate:self];
        [[rootTVC tableView] setDataSource:self];
        [rootTVC setTitle:@"Root Table"];
    
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootTVC];
        [rootTVC release];
        [navController setTitle:@"My Table"];
    
        UIViewController *anotherViewController = [[UIViewController alloc] init];
        [anotherViewController setTitle:@"Not the table"];
    
        UITabBarController *tbc = [[UITabBarController alloc] init];
        [tbc setViewControllers:[NSArray arrayWithObjects:navController, anotherViewController, nil]];
        [self setNavController:navController];
        [navController release];
        [anotherViewController release];
        [[self window] setRootViewController:tbc];
        [tbc release];
    
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 10;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString *reuseIdentifier = @"foo";
        UITableViewCell *cell = [[tableView dequeueReusableCellWithIdentifier:reuseIdentifier] retain];
        if (! cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        }
        [[cell textLabel] setText:[NSString stringWithFormat:@"Row %d", [indexPath row]]];
        return [cell autorelease];
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    { 
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        UITableViewController *newTVC = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
        [newTVC setTitle:[NSString stringWithFormat:@"Table %d", [indexPath row]]];
        [[newTVC tableView] setDelegate:self];
        [[newTVC tableView] setDataSource:self];
        [[self navController] pushViewController:newTVC animated:YES];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a

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.