PDA

View Full Version : TabBarController + Navigation: Table is Blank




Paix247
Feb 18, 2009, 01:37 PM
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.


//
// SectionsViewController.h
//

#import <UIKit/UIKit.h>
@class DataController;
@interface SectionsViewController : UITableViewController {
DataController *dataController;
}
@property (nonatomic, retain) DataController *dataController;
@end
//
// 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:@"MyIdentifier"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MyIdentifier"] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

NSDictionary *itemAtIndex = (NSDictionary *)[dataController objectInListAtIndex:indexPath.row];
cell.text = [itemAtIndex objectForKey:@"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.h
//

#import <UIKit/UIKit.h>
@class DataController;
@class SectionsViewController;
@interface SectionsAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;

IBOutlet UITabBarController *rootController;
DataController *dataController;

}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UITabBarController *rootController;

@property (nonatomic, retain) DataController *dataController;

@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
http://berger-ramirez.com/branberger/Picture1.png
//
http://berger-ramirez.com/branberger/Picture2.png
//
http://berger-ramirez.com/branberger/Picture3.png