TableView:获取HeaderCell中textField的值

时间:2015-10-10 16:08:06

标签: swift

如何获取UITableView的标题Cell的值? 使用以下代码,我得到一个部分中的单元格的值。但是我怎么能改变它,它将与标题单元格一起使用?

      let indexPath = NSIndexPath(forRow: row, inSection: h)
      tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Top, animated: false)

      let currentCell = tableView.dequeueReusableCellWithIdentifier("TeamInput", forIndexPath: indexPath) as! TeamInputTableViewCell

1 个答案:

答案 0 :(得分:0)

如果您想访问UITableView中的headerView,可以这样做:

let headerView = tableView.headerViewForSection(indexPath.section)

顺便说一下,如果要访问表视图中的现有单元格,则不应使用dequeueReusableHeaderFooterViewWithIdentifier,因为该方法会从队列中返回一个新单元格而不是当前显示的单元格。要访问其中一个显示的单元格,您应该使用:

let cell = tableView.cellForRowAtIndexPath(indexPath)