TabBarController + Navigation: Table is Blank

Discussion in 'iPhone/iPad Programming' started by Paix247, Feb 18, 2009.

  1. macrumors 6502

    Joined:
    Jul 26, 2006
    Location:
    Minneapolis
    #1
    I have a Tab Bar Controller app all set up with 4 tabs - (it finally starts without errors or exceptions!). Two tabs display a simple tableview, one tab shows a static 'about' page, and the 4th tab shows a Navigation Controller.

    I have everything working except the table in my Navigation tab is blank. The controller class is working somewhat, because the name of the Navigation shows up both in the Tab title and in the Navigation Bar title; however, my table is blank!

    Basically, I tried to tie in Apple's Simple Drill Down app into my Tab Bar Controller, and I think I did something wrong in the translation.
    I'll post some of my code & screen shots, and let me know if you need to know anything else.


    //
    // SectionsAppDelegate.m
    //

    #import "SectionsViewController.h"
    #import "DataController.h"
    #import "DetailViewController.h"


    @implementation SectionsViewController
    @synthesize dataController;

    - (void)awakeFromNib {
    self.title = NSLocalizedString(@"Restaurants", @"Master view navigation title");
    }

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [dataController countOfList];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mad:"MyIdentifier"];
    if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:mad:"MyIdentifier"] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    NSDictionary *itemAtIndex = (NSDictionary *)[dataController objectInListAtIndex:indexPath.row];
    cell.text = [itemAtIndex objectForKey:mad:"title"];
    return cell;
    }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    DetailViewController *detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];

    detailViewController.detailItem = [dataController objectInListAtIndex:indexPath.row];

    [[self navigationController] pushViewController:detailViewController animated:YES];
    [detailViewController release];
    }

    - (void)dealloc {

    [dataController release];
    [super dealloc];
    }
    @end
    //
    // SectionsAppDelegate.m
    //

    #import "SectionsAppDelegate.h"
    #import "SectionsViewController.h"
    #import "DataController.h"

    @implementation SectionsAppDelegate
    @synthesize window;
    @synthesize dataController;
    @synthesize rootController;

    - (void)applicationDidFinishLaunching:(UIApplication *)application {

    [window addSubview:rootController.view];
    [window makeKeyAndVisible];
    }


    - (void)dealloc {

    [rootController release];
    [window release];
    [super dealloc];
    }
    @end
    [​IMG]
    //
    [​IMG]
    //
    [​IMG]
     

Share This Page