我有一个自定义 UITableViewCell
和一个名为 CellLabel
的 UILabel
。我希望能够在某个 tableView 部分
访问此标签,例如第 3 节并为其提供一个字符串以在不使用数组和 arrayName[indexPath.section]
的情况下显示。
最佳答案
您可以在 cellForRowAtIndexPath
覆盖 TableView
中捕获它
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("YourCustomCellRegisterName") as YourCustomCell
if(indexPath.section == 3){
cell.CellLabel.text = "foo"
}
return cell
}
关于ios - Swift:如何访问某个 tableView 部分中自定义单元格中的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39641716/