带有索引的 iPhone UITableView 我可以为每个不同的单元格推送不同的详细视图吗?

发布于 2024-08-30 15:38:56 字数 103 浏览 3 评论 0原文

我知道可以创建一个侧面有索引、顶部有搜索栏的表,用户可以输入该搜索栏来查找项目,但是是否可以对表说,如果数组等于“item1”push视图1?我想为每个单元格推送不同的视图。有人有什么建议吗?

I know its possible to create a table that has an index on the side and a search bar at the top that a user can type in to find an item, but is it possible to say to the table if array isEqual to "item1" push view1? I would like to push a different view with each cell. Anyone have any advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深已缘浅 2024-09-06 15:38:56

当然。只需根据 tableView:didSelectRowAtIndexPath: 中单元格的 indexPath 创建适当的视图(控制器)即可。

Sure. Just create the appropriate view (controller) depending on the cell's indexPath in tableView:didSelectRowAtIndexPath:.

南街九尾狐 2024-09-06 15:38:56

根据索引路径创建单元格。如果提前创建所有单元格,请按行索引将它们存储在数组中。如果您根据需要创建它们,请执行以下操作:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *result;
    switch ( [indexPath row] ) {
    default: result = [self tableView:tableView normalCellForRowAtIndexPath:indexPath]; break;
    case 3: result = [self tableView:tableView detail3CellForRowAtIndexPath:indexPath]; break;
    case 5: result = [self tableView:tableView detail5CellForRowAtIndexPath:indexPath]; break;
    }
    return result;
}

Create the cell based on the index path. If you create all the cells ahead of time, store them in an array by row index. If you are creating them as needed, do something like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *result;
    switch ( [indexPath row] ) {
    default: result = [self tableView:tableView normalCellForRowAtIndexPath:indexPath]; break;
    case 3: result = [self tableView:tableView detail3CellForRowAtIndexPath:indexPath]; break;
    case 5: result = [self tableView:tableView detail5CellForRowAtIndexPath:indexPath]; break;
    }
    return result;
}
如歌彻婉言 2024-09-06 15:38:56

查看《Beginning iPhone Development》一书中的示例程序。您必须注册,但它是免费的。您应该专门查看第 9 章名为 Nav 的示例代码。准确地向您展示您所需要的内容。这是我关于这个主题的第一本书,非常值得。

http://www.iphonedevbook.com/forum/viewforum.php?sid= 3010c045df967353c6b3894889e6b8f5

干杯!

Check out the sample programs from the book Beginning iPhone Development. You must sign up, but its free. You should look specifically at chapter 9's sample code called Nav. Shows you exactly what you need. This was my first book on the subject and was well worth it.

http://www.iphonedevbook.com/forum/viewforum.php?sid=3010c045df967353c6b3894889e6b8f5

Cheers!
Ken

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文