use*_*428 1 uitableview ios swift
我的应用程序中有一些代码可以在单击时扩展单元格.问题是我还没弄明白如何只扩展已被挖掘的单元格.目前我的代码只扩展了所有单元格.
这是我的代码:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedRowIndex = indexPath
tableView.beginUpdates()
tableView.endUpdates()
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == selectedRowIndex.row {
if cellTapped == false {
cellTapped = true
return 141
} else {
cellTapped = false
return 70
}
}
return 70
}
Run Code Online (Sandbox Code Playgroud)
我只需要扩展已被挖掘的单元格,我需要做什么?
lee*_*ger 16
以下对我有用.单元为70高,并在敲击时扩展:
class ViewController: UITableViewController {
var cellTapped:Bool = true
var currentRow = 0;
Run Code Online (Sandbox Code Playgroud)
然后我稍微修改了以下两种方法:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var selectedRowIndex = indexPath
currentRow = selectedRowIndex.row
tableView.beginUpdates()
tableView.endUpdates()
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == currentRow {
if cellTapped == false {
cellTapped = true
return 141
} else {
cellTapped = false
return 70
}
}
return 70
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6201 次 |
| 最近记录: |