2017-10-03 10 views
-1

にNIBをロードできませんでしたが、私のコードです:エラー再利用可能なヘッダを設定する:「私は、再利用可能なヘッダーを使用するように私のコードを変更しようとしていますし、それがここviewForHeaderInSection にクラッシュしているバンドル

class CaptionHeaderCell: UITableViewHeaderFooterView { 
    override func awakeFromNib() { 
     super.awakeFromNib() 
    } 
} 

override func viewDidLoad() { 
     super.viewDidLoad() 
self.tableView.register(UINib(nibName:"CaptionHeaderCell", bundle: nil), forHeaderFooterViewReuseIdentifier: "CaptionHeaderCell") 
} 


func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
     let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CaptionHeaderCell") as! CaptionHeaderCell 


     header.contentView.backgroundColor = "c0efff".hexColor 
     return header 
    } 

enter image description here

enter image description here

enter image description here

エラーがで起こっています ヘッダー= tableView.dequeueReusableHeaderFooterView(withIdentifier: "CaptionHeaderCell")を! CaptionHeaderCell

、エラーメッセージは次のとおりです。 :名前の 'NSBundle(ロード)' 'CaptionHeaderCell'」

+0

エラーは何ですか?どのラインで正確にエラーが発生しますか? – rmaddy

+0

ソートエラーログがある場合は、それを質問で更新してください。分析する方が良いでしょう。 – Bharath

+0

チケットを更新しました – user1079052

答えて

0

レジスタに変更する必要があります。 self.tableView.register(CaptionHeaderCell.self、forHeaderFooterViewReuseIdentifier:「CaptionHeaderCell ")

関連する問題