0

I'm having a problem pushing a UITableViewController onto a NavigationController. With the following code:

ProblemEditController *problemEditController = [[[ProblemEditController alloc] initWithNibName:@"ProblemEditController" bundle:nil] retain];
problemEditController.problem = [[Problem alloc] init];
[self.navigationController pushViewController:problemEditController animated:YES];
[problemEditController release];

The navigation controller works as expected, however, the table view is not showing. numberOfSectionsInTableView is being called on my UITableViewController, but numberOfRowsInSection and cellForRowAtIndexPath aren't being called, and the view shows up blank.

Is there something obvious I am missing?

EDIT

I've changed something in the nib file (stupidly, can't remember what), and I'm seeing numberOfRowsInSection being called now.

2 Answers 2

1

OK, I've found out what I was doing wrong. I had added a TableViewController to my nib rather than just added a table view.

I'd basically messed up the connection to view in IB. For future reference, this is what a custom UITableViewController should look like in IB:

alt text http://pix.im/files/134/scaled.jpg?1239453713

Now I feel like a cretin.

Sign up to request clarification or add additional context in comments.

1 Comment

At times, I've felt Interface Builder is a hinderance, since all the advanced sample projects in the iOS library programatically create many of their controllers, thus making it sometimes difficult to figure out where the nib files live in the whole application life cycle.
0

Try now using retain or release on **problemEditController*.

This piece of code works fine for me:

formationsController = [[FormationsController alloc] initWithNibName:@"Formations" bundle:nil];
[navigationController pushViewController:formationsController animated:YES];

5 Comments

Unfortunately this didn't work - same problem. I don't understand why the view isn't being shown when the numberOfSectionsInTableView function is called.
Try showing the view with prensetModalViewController instead of pushing it. To see if something changes.
Same thing - a blank view is displayed.
I've changed something in the nib file (stupidly, can't remember what), and I'm seeing numberOfRowsInSection being called now.
No prob! Good luck w/ your project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.