1
我在处理swift表格时遇到了问题。表格单元SegueWay无法运行 - SWIFT
当我点击一个单元格时,我想要转到另一个页面,我已经创建了segueWay连接和其他一切。
但是,当在模拟器中运行此功能无法正常工作时,请单击一个单元格,然后单击任何内容。
的TableView代码:
import UIKit
class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "LabelCell")
cell.textLabel?.text="conteudo da linha"
cell.detailTextLabel?.text = "Details"
return cell
}
/* func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
}*/
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
print("Hello")
if (segue.identifier == "testing"){
let vc = (segue.destinationViewController as! EditarController)
}
}
}
因为这个函数在你点击tableview中的一行时被调用 –