【发布时间】:2015-08-27 10:40:24
【问题描述】:
我有一个带有原型单元格的 tableView;用这个func 设置单元格高度
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return cellHeight
}
有了这个action,我改变了 UIButton 内部的单元格高度
@IBAction func changeCellHeight(sender: UIButton)
{
if cellHeight == 44
{
cellHeight = 88
} else {
cellHeight = 44
}
tableView.beginUpdates()
tableView.endUpdates()
}
现在我只需要更改选定单元格的高度(不是每个单元格);所以我定义
var index: NSIndexPath! 我实现了这个func
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
index = self.tableView.indexPathForSelectedRow()!
println("Cella " + "\(index)")
}
正如我在控制台中预期的那样,Xcode 会打印选定的单元格 (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0})。
所以我的麻烦是如何在IBAction 中使用var index。
提前致谢。
【问题讨论】:
标签: swift ibaction didselectrowatindexpath nsindexpath