2010-02-26 89 views

回答

1

我不认为你会受益于一个完整的样本。下面的函数虽然有帮助。您需要实现didSelectRowAtIndexPath的委托方法,并且这是您为新视图创建新控制器并加载它的位置。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     YourViewController *controller = [[YourViewController alloc] initWithNibName:@"YourViewController"bundle:nil];   
     [[self navigationController] pushViewController:yourViewController animated:YES]; 
     [yourViewController release]; // don't leak memory 
     } 

根据行号,您可以决定加载哪个nib。

0

请看下面链接

http://adeem.me/blog/2009/05/19/iphone-programming-tutorial-part-1-uitableview-using-nsarray/

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

编写代码来打开你这个方法在新的观点与你的代码是

- (空)的tableView:(UITableView的*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath if(indexPath.row == 0) { //您的cod e在第一行的选择上打开新视图。 } if(indexPath.row == 1) //您的代码打开新视图上的第二行选择在这里。 }

}

相关问题