【发布时间】:2015-06-22 19:18:11
【问题描述】:
尝试使用以下方法查找 TableViewController 中触及的行号:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let indexPath = tableView.indexPathForSelectedRow();
let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as UITableViewCell?;
NSLog("Current Cell = %d", currentCell!)
}
如果您按下相同的单元格,它会返回相同的数字,但会出现非常大的数字,例如 410772272 或 409747056。在两个单元格测试中,我期待的是 1 或 2。如果您使用 %i 或返回相同的数字%d。
任何见解或我是否完全使用了错误的电话。
【问题讨论】:
-
currentCell!是指向表格视图单元格的 指针 ...您的意思是NSLog("Current row = %d", indexPath.row)吗?
标签: swift didselectrowatindexpath