从一个视图控制器转到不同的控制器 [英] Segue to different controllers from one view controller

查看:30
本文介绍了从一个视图控制器转到不同的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含几个不同原型单元格的表格视图.我想让一个原型单元与一个控制器相连,其余的单元不应该是可点击的,即没有 seg.

I have a table view with a few different prototype cells. I want to have one prototype cell segued to one controller and the rest should not be clickable i.e. no seg.

现在,我有一个按钮成功链接到控制器,但是当我点击连接到不同控制器(在故事板中)的 tableview 原型单元格时,没有任何反应.我也没有收到任何错误.

Right now, I have one button linked to a controller successfully but when I tap on the tableview prototype cell which is segued to a different controller (in the storyboard) nothing happens. I don't get any error either.

解决这个问题的最佳方法是什么?我可以在故事板中制作两个不同的转场吗?或者我是否需要在 tableview 方法中实现某些东西在索引路径上选择行,以某种方式获取与单击的行关联的类并以编程方式转到不同的屏幕?就像是:func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {println("这里")//self.performSegueWithIdentifier("profileSeg", sender: self)}

What is the best way to go around this? Can I make two different segues in the storyboard? Or do I need to implement something in the tableview method did select row at index path, somehow grab the class associated with the row clicked and programmatically segue to a different screen? Something like: func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { println("here") //self.performSegueWithIdentifier("profileSeg", sender: self) }

当我选择一个单元格时,我没有在此处获取 println,是的,我已在 viewdidload 中分配了委托.

I am not getting the println here when I select a cell and yes I have assigned the delegate in viewdidload.

编辑

我刚刚意识到我在解释问题时犯了一个错误.我实际上在底部有一个链接到一个视图控制器的视图.它不是 tableview 行...这是有效的 seg.但是我已经 ctrl 从一种类型的单元格拖动到第二个控制器,并且该段不起作用.还有 3 种其他类型的细胞,它们都没有附加 seg.这与问题有关吗?

I've just realised I made a mistake when explaining the question. I actually have a view at the bottom which links to one view controller. It is not a tableview row... This is the seg that works. But I have ctrl dragged to from one type of cell to a second controlleR and that seg is not working. There are also 3 other types of cells none of which have segs attached. Is this anything to do with the issue?

推荐答案

如果 didSelectRowAtIndexPath 不起作用,可能是由于您的 UITableViewDelegate 没有设置,或者,有可能你的 UITableView 的选择已经关闭,需要打开,看图片找到方法.

If didSelectRowAtIndexPath not working, it can be caused by either your UITableViewDelegate has not been set, or, it might possible that Selection of your UITableView has been turned off, need to Turn on, see image to find how.

干杯.

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

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