2016-08-17 7 views
2

これは残念ながら、カスタムヘッダビューが表示されない私のコードスウィフト - セクションのヘッダーは

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
    return 61.0 
} 

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 

    let headerCell = tableView.dequeueReusableCellWithIdentifier("CustomHeaderCell") as! CustomHeaderCell 
    headerCell.titleLabel.text = "user data" 
    return headerCell 

} 

func numberOfSectionsInTableView(tableView: UITableView) -> Int { 

    return 2 
} 

で表示されません。しかし

、私が使用するだけで、この:

func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
    return "user data" 
} 

セクションヘッダが存在している、私のカスタムヘッダビューのコードで何が間違っているのですか?彼らはそれを動作させるために

をtableViewDelegateに属するものの

答えて

2

は私の悪い、私は盲目的にデータソースにこれらの機能を置く:

extension UserProfileDelegate: UITableViewDelegate { 

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 

    let headerCell = tableView.dequeueReusableCellWithIdentifier("CustomHeaderCell") as! CustomHeaderCell 
    headerCell.titleLabel.text = "user data" 
    return headerCell 

} 

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
    return 61.0 
} 

} 
関連する問題