2016-12-07 63 views
1

我在我的标题部分找不到任何文本。这是我如何设置页眉部分:viewForHeaderInSection部分不显示标题

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return myDataSource[section].otherKeyValues.count 
} 

override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    return myDataSource.count 
} 

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell: AccordionDetailTableViewCell = (NSBundle.mainBundle().loadNibNamed("AccordionDetailTableViewCell", owner: self, options: nil).first as? AccordionDetailTableViewCell)! 
    //  cell.headerLabel!.text = "This is a test" 
    let currentCellData = myDataSource[indexPath.section] 
    cell.headerLabel!.text = currentCellData.otherKeyValues[indexPath.row].key 
    cell.detailLabel!.text = currentCellData.otherKeyValues[indexPath.row].value 
    return cell 

} 

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

    let view: AccordionHeaderView = (NSBundle.mainBundle().loadNibNamed("AccordionHeaderView", owner: self, options: nil).first as? AccordionHeaderView)! 
    view.tag = section 
      view.delegate = self 
    view.titleLabel!.text = myDataSource[section].dateCreated == nil || myDataSource[section].dateCreated == "" ? " " : myDataSource[section].dateCreated 
    return view 
} 

项目显示在单元格,即使我设置view.titleLabel!.text = "Hello"然后你好不会出现。

我使用UIViewController实施FZAccordionTableView

我在做什么错在这里?

+1

请实现你的tableView – Aakash

+0

的heightForHeaderInSection方法,我已经实现了你的观点,以UITableViewAutomaticDimension现在什么也出现甚至细胞没有见过 – Sam

+0

给他们的静态高度为并查看它们是否可见 – Aakash

回答

1

您需要实现UITableview委托方法像heightForHeaderInSection

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

     return 30 

}