1
我环顾四周寻找其他答案,但似乎无法得到任何工作。我已经实现了这个代码:如何在选择单元格时更改单元格的高度?
var selectedCellIndexPath: NSIndexPath?
let selectedCellHeight: CGFloat = 88.0
let unselectedCellHeight: CGFloat = 51.0
// Override to support editing of individual itemCells
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if selectedCellHeight == indexPath {
return selectedCellHeight
}
return unselectedCellHeight
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if selectedCellIndexPath != nil && selectedCellIndexPath == indexPath {
self.selectedCellIndexPath = nil
} else {
self.selectedCellIndexPath = indexPath
}
tableView.beginUpdates()
tableView.endUpdates()
if selectedCellIndexPath != nil {
// THis ensure, that the cell is full visile once expended
tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .None, animated: true)
}
}
而且我是从其他StackOverflow的答案,但是当我运行我的应用程序的电池只能表明它已被选中(通过被着色),然后进行任何其他操作。任何帮助都会很棒!我是一个开始的开发者!
谢谢@Aaron Brager!我还是新手,所以这对我来说并不那么简单!我非常感谢帮助。 – KeithFrazier98
@ KeithFrazier98乐意帮忙!如果这解决了您的问题,请点击我答案左侧的复选框。 (这会告诉其他用户您不再需要帮助。) –