[英]use segue from different tableViewCell at a tableView push to different viewController Can be implementation at storyboard
I always have a question that using segue from different tableViewCell at a same tableView push to different viewController with storyboard can be implementation? 我总是有一个问题,可以在同一tableView上使用来自不同tableViewCell的segue推送到带有Storyboard的不同viewController上吗? Eg clicked first cell push to the first view controller, selected second cell push to the second view controller, and the whole process uses storyboard segue.
例如,单击第一个单元格将其推送到第一视图控制器,选择第二个单元格将其推送到第二视图控制器,然后整个过程将使用情节提要segue。 Can have anyone tell me this whether be come true?
谁能告诉我这是否成真?
Create the segue in your storyboard for each kind of cell : 在情节提要中为每种单元格创建segue:
Then in your method func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
you should specify the kinf of the cells you implement in your tableView, with their Reuse Identifier. 然后在方法
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
,应指定在tableView中实现的单元格的类型以及其重用标识符。 Then the appropriate segue will be called. 然后将调用适当的segue。
是的,您可以使用,但是您必须将逻辑放入prepareForSegue
方法中,但这不是最好的方法,您应该使用UITableViewDelegate
方法override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
这将给您indexPath,然后可以实例化到所需的任何ViewController。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.