每个单元格打开一个新的xibs的uitableview

时间:2010-02-26 16:57:26

标签: iphone uitableview sdk

寻找一个教程,uitableview将每个单元格打开成一个新的xibs。

2 个答案:

答案 0 :(得分: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
        }

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

答案 1 :(得分: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/

编写代码,在此方法下打开新视图,代码为

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {        如果(indexPath.row == 0)        {               //您在第一行选择中打开新视图的代码就在这里。        }        如果(indexPath.row == 1)        {                //您在第二行选择时打开新视图的代码就在这里。        }

}