【发布时间】:2011-05-01 12:46:28
【问题描述】:
我正在开发一个基于导航的应用程序。 我的 rootViewController 包含 3 个单元格 - 当第一个被按下时,一个 UIViewController 被按下(这个工作) - 问题在于应该推送 UITableViewController 的第 2 和第 3 个单元格
应用程序运行时没有错误,也没有崩溃,但是当我导航到 tableview 时,会看到一个空表,其中没有任何元素。
这部分代码有问题吗? :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:@"Introduction" bundle:nil];
detailViewController.title=@"Introduction";
UITableViewController *myPictures = [[UITableViewController alloc] initWithNibName:@"Pictures" bundle:nil];
myPictures.title=@"Pictures";
UITableViewController *myImages = [[UITableViewController alloc] initWithNibName:@"ImagesViewController" bundle:nil];
myImages.title=@"Images";
// Pass the selected object to the new view controller.
if (0 == indexPath.row)
[self.navigationController pushViewController:detailViewController animated:YES];
if (1== indexPath.row)
[self.navigationController pushViewController:myPictures animated:YES];
if (2== indexPath.row)
[self.navigationController pushViewController:myImages animated:YES];
[detailViewController release];
[myPictures release];
[myImages release];
【问题讨论】:
-
只有在选择了相应的行以最小化内存占用时,才应该创建视图控制器的实例。你能解释一下“但是当我导航到表格视图时”是什么意思吗?你的意思是,通过单击应该显示 viewController 的单元格?
标签: iphone uitableview xcode4 navigationcontroller