0
私はUITableViewと "A"と呼ばれるボタンを持つUIViewControllerを持っています。このテーブルにはセクションと行があります。今私のシナリオでは、「A」がクリックされたときにセクションをハイライトしたいと思っています。私はviewForHeaderInSectionでこの作業をしたくないので、テーブルビュー全体をリロードする必要はありません。ボタンをクリックしたときのコードは次のとおりです。UITableView全体を更新せずにセクションの背景色を更新
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)
}
ボタンのクリックで何とかシアン色が表示されません。誰でも迅速に適切なソリューションを投稿できますか?
感謝を。それが私の問題を解決した – neena