★ ExtraViewをUITableViewのSectionHeaderに使用する場合の注意
@IBOutlet var sectionTitleView: SectionHeaderView!
// Custom SectionHeader
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// コピーしたViewを渡さないと消えたり挙動が変になる。
// ※プロパティに値を設定する場合はコピーする前に行う
sectionTitleView.sectionTitleLabel.text = sectionTitleArray[section]
let copiedSection = NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDataWithRootObject(self.sectionTitleView)) as! SectionHeaderView
return copiedSection
}
// SectionHeader Height
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return self.sectionTitleView.frame.size.height
}