我的表视图上加载了一些表格单元格。这些单元格中的每个单元格在右上角有一个箭头按钮,其中一行的高度会增加,还有一些按钮会暴露出来。单击按钮会再次隐藏按钮&高度会像以前一样降低。密码是这样给出的。
func moreOptionsBtnTapped(cell: CustomersTableViewCell) {
if i == 0 {
if let indexPath = tableView?.indexPath(for: cell) {
selectedIndex = indexPath as NSIndexPath
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.fade)
}
i += 1
} else {
if let indexPath = tableView?.indexPath(for: cell) {
selectedIndex = indexPath as NSIndexPath
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.fade)
}
i = 0
}
}heightForRowAtIndexPath的名称为:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath == selectedIndex as IndexPath {
if i == 0 {
return 92
} else {
return 66
}
}
return 66 }
现在的问题是,我也有一个搜索栏顶部和点击该搜索栏,如果额外的按钮暴露在桌面查看单元格,然后我希望他们被最小化。只是把它们藏起来是没用的。已经试过了。
希望有人能帮忙..。
发布于 2017-12-04 10:35:36
当您单击搜索栏时,您将得到对UISearchBarDelegate方法的调用,如
optional public func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool // return NO to not become first responder在此方法中,您可以更改i值并重新加载表视图。在这种方法中,您不能获得行的indexPath,这就是为什么您使用.
self.tableview.relaodData()https://stackoverflow.com/questions/47631204
复制相似问题