我正在開發基於導航的應用程序。 我RootViewController的包含3個小區 - 當第一個被按下一個UIViewController被推(這適用) -The的問題是與將要用於推動一個UITableViewControlleriphone UITableVIew(基於導航)
該應用沒有運行第二和第三細胞錯誤,它不會崩潰,但是當我導航到tableview時,查看一個沒有任何元素的空表。
這部分代碼有問題嗎? :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:@"Introduction" bundle:nil];
[email protected]"Introduction";
UITableViewController *myPictures = [[UITableViewController alloc] initWithNibName:@"Pictures" bundle:nil];
[email protected]"Pictures";
UITableViewController *myImages = [[UITableViewController alloc] initWithNibName:@"ImagesViewController" bundle:nil];
[email protected]"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];
您應該創建viewControllers僅當實例相應的行已被選擇來最大限度地減少你的內存佔用量,你能解釋一下你的意思嗎?「但是當我導航到tableview」時,你的意思是,通過點擊應該顯示viewController的單元格嗎? – 2011-05-01 13:00:15
yes,c舔細胞.. – 2011-05-01 13:45:39