更新部分背景颜色而不刷新整个 UITableView
update section background colour without refreshing the whole UITableView
我有一个 UIViewController,它有一个 UITableView 和一个名为 "A" 的按钮。此 table 包含部分和行。现在在我的场景中,我想在 "A" 单击时突出显示一个部分。我不想在 viewForHeaderInSection 中做这项工作,因为我不想重新加载整个 table 视图。我现在尝试点击按钮的代码如下,
public func scrollToSection(sectionNumber:Int)
{
let indexPath = NSIndexPath(forRow: 0, inSection: sectionNumber)
let headerView = tableView.headerViewForSection(indexPath.section)
tableView.beginUpdates()
headerView?.contentView.backgroundColor = UIColor.cyanColor()
tableView.endUpdates()
tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Middle, animated: true)
}
但不知何故,点击按钮时它没有显示青色。谁能 post 在 swift 中找到合适的解决方案?
我有一个 UIViewController,它有一个 UITableView 和一个名为 "A" 的按钮。此 table 包含部分和行。现在在我的场景中,我想在 "A" 单击时突出显示一个部分。我不想在 viewForHeaderInSection 中做这项工作,因为我不想重新加载整个 table 视图。我现在尝试点击按钮的代码如下,
public func scrollToSection(sectionNumber:Int)
{
let indexPath = NSIndexPath(forRow: 0, inSection: sectionNumber)
let headerView = tableView.headerViewForSection(indexPath.section)
tableView.beginUpdates()
headerView?.contentView.backgroundColor = UIColor.cyanColor()
tableView.endUpdates()
tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Middle, animated: true)
}
但不知何故,点击按钮时它没有显示青色。谁能 post 在 swift 中找到合适的解决方案?