UITableViewController和NavigationController

时间:2009-04-11 10:50:07

标签: iphone cocoa-touch

我在将UITableViewController推送到NavigationController时遇到问题。使用以下代码:

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

导航控制器按预期工作,但表格视图未显示。我的UITableViewController正在调用numberOfSectionsInTableView,但是没有调用numberOfRowsInSection和cellForRowAtIndexPath,并且视图显示为空白。

我有什么明显的遗失吗?

修改

我在nib文件中更改了一些内容(愚蠢的,不记得是什么),我现在正在看到numberOfRowsInSection被调用。

2 个答案:

答案 0 :(得分:1)

好的,我已经发现我做错了什么。我在我的笔尖中添加了一个TableViewController,而不仅仅是添加了一个表视图。

我基本搞砸了在IB中查看的连接。为了将来参考,这是自定义UITableViewController在IB中的样子:

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

现在我觉得自己像个傻瓜。

答案 1 :(得分:0)

现在尝试使用** problemEditController *上的retain或release。

这段代码对我来说很好用:

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