从一个 tableView 创建不同的 segue [英] Create different segues from one tableView

查看:22
本文介绍了从一个 tableView 创建不同的 segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中创建了一个菜单.

I created a menu inside of my app.

菜单有 4 个单元格,通过修改原型单元格创建.

The menu has 4 cells, which are created by modifying a prototype cell.

这些单元格中的每一个都应该对 4 个 ViewController 之一执行转场.

Each of those cells should perform a segue to one of 4 ViewControllers.

我怎么能意识到这一点?有什么想法吗?

How can I realize this? Any ideas?

推荐答案

您可以:

1) 创建 4 个原型单元,每个单元直接连接到其各自的 viewController.在这种情况下,每个原型单元格都有自己的标识符(例如 "cell1""cell2""cell3">"cell4") 然后在 cellForRowAtIndexPath 中使用适当的行标识符出列:["cell1", "cell2", "cell3", "cell4"][indexPath.row].

1) Create 4 prototype cells having each one wired directly to its respective viewController. In this case, each give each prototype cell its own identifier (for example "cell1", "cell2", "cell3" and "cell4") and then in cellForRowAtIndexPath dequeue using the appropriate identifier for the row: ["cell1", "cell2", "cell3", "cell4"][indexPath.row].

2) 从viewController 顶部的viewController 图标连接segue,提供segue 标识符,并使用didSelectRowAtIndexPath 中的performSegueWithIdentifier 触发适当的segue.

2) Wire the segues from the viewController icon at the top of your viewController, give the segues identifiers, and trigger the appropriate segue with performSegueWithIdentifier in didSelectRowAtIndexPath.

这篇关于从一个 tableView 创建不同的 segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆