views:

108

answers:

3

Hi there,

I've tried to ask this before, but nothing got answered. Basically, I would like someone to explain to me how to create a table, which when a cell is tapped, pushes the user to the next view for that cell. I have this so far:

Click here to view what I have.

I would further like to, say when CSS is tapped, it goes to a new view which has another table in it. This table would then take the user to a detail view, which is scrollable and you can switch pages through it.

I would appreciate longer, more structured tutorials on how to do each and every bit to get it to work.

Here's my array in my implementation file:

- (void)viewDidLoad {
    arryClientSide = [[NSArray alloc] initWithObjects:@"CSS", @"HTML", @"JavaScript", @"XML", nil];
    arryServerSide = [[NSArray alloc] initWithObjects:@"Apache", @"PHP", @"SQL", nil];
    self.title = @"Select a Language";
    [super viewDidLoad];
}

and my .h:

@interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    IBOutlet UITableView *tblSimpleTable;
    NSArray *arryClientSide;
    NSArray *arryServerSide;
}

My current code crashes the script, and this error is returned in the console:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "NextView" nib but didn't get a UITableView.'

If that error is the source of why it's not pushing, then an explanation of how to remedy that would also be appreciated

NextViewController implementation

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    arryBasicCSS = [[NSArray alloc] initWithObjects:@"Implement", @"Syntax", @"Classes and IDs", @"Fonts", @"Backgrounds", @"Lists", @"Links",   nil];
    arryIntermediateCSS = [[NSArray alloc] initWithObjects:@"Padding and Margin", @"Alignment and Floating", @"Pseudo-class and Element", @"Opacity and Display", nil];
    arryAdvancedCSS = [[NSArray alloc] initWithObjects:@"Sprites", @"Attribute Selectors", @"Animation", nil];
    self.title = @"CSS";
    [super viewDidLoad];
}

- (IBAction) changeItemTable:(NSString *)str{
    tblCSS = str;
}

NextViewController.h

@interface NextViewController : UITableViewController {
    IBOutlet UITableView *tblCSS;
    NSArray *arryBasicCSS;
    NSArray *arryIntermediateCSS;
    NSArray *arryAdvancedCSS;
}

Many thanks, Jack

+1  A: 

First the "Terminating app due to uncaught exception" error. I noticed that your RootViewController contains:

    IBOutlet UITableView *tblSimpleTable;

Check to make sure that you have properly connected RootViewController's "view" property to your UITableView, and not just connected tblSimpleTable to your TableView. The view property in a UITableViewController needs to point to a UITableView.

Assuming that tblSimpleTable is the TableView that you want to control from this UIViewController, delete this outlet and just use the "view" or "tableView" property of the UITableViewController, they will both be valid.

For your original problem of hierarchical table views, have at look at this sample project:

TheElements

Kenny
A: 

See this: http://adeem.me/blog/2009/05/19/iphone-sdk-tutorial-part-2-navigation-in-uitableview/

jrtc27
Will that work for grouped tables? Also, how can assign a new view for each item of a table?
Jack Griffiths
+1  A: 

If the SDK's own documentation isn't providing the answers you need, try a Google search for UITableView Interface Builder tutorial. That should return a number of useful step-by-step tutorials.

The reason you're getting the exception is because you haven't connected your tblSimpleTable outlet to your table view object in Interface Builder.

IB Outlets

Open NextView.xib in Interface Builder. Select the File's Owner object. Open the Inspector pane, and you should see something similar to the image I've posted. Instead of "searchTable" yours should read "tblSimpleTable". To connect the outlet to the file's owner, click-and-hold on the circle to the right of "tblSimpleTable" and drag the line to your "tblSimpleTable" object.

alt text

Save your changes, rebuild your project.

Gordon Hughes
Thanks. I think I've gotten myself in a loop of confusion: I've got references all over the place. When I try and attempt what you've done, I get these two errors. BTW, I manually created tblCSS via IB. Not sure if you mean I need tblSimpleTable. I updated my post with the code I have in my NextViewController files.
Jack Griffiths