我有一个 custom cell class
和一个包含该 cell 设计的 custom nib
。在我的 storyboard
中,我没有看到将 tableview
连接为 segue
的方法(就像你对原型(prototype)单元格所做的那样)我从那以后就有了我的单元格是通过 tableView:cellForRowAtIndexPath
添加的。
有没有办法连接这个 segue,这样我就可以继续使用 Storyboard将单元格连接到详细 View Controller ?
这是我的 tableView:cellForRowAtIndexPath
代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell") as MyTableViewCell?
if (cell == nil) {
tableView.registerNib(UINib(nibName: "MyTableViewCell", bundle: NSBundle(identifier: "com.company.InterfaceComponents")), forCellReuseIdentifier: "cell")
cell = tableView.dequeueReusableCellWithIdentifier("cell") as MyTableViewCell?
}
return cell!
}
最佳答案
我发现我可以做的是添加一个手动转场(通过从 Controller 拖动)到详细信息 Controller (如使用标识符显示转场:“showDetails”)。然后我可以在我的 TableView 中添加以下代码:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.performSegueWithIdentifier("showDetails", sender: tableView)
}
这会给我想要的功能。
关于swift - 当我从 Nib 加载单元格时,UITableViewCell 会转到详细 View 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26378210/