繁体   English   中英

Swift:如何访问某个 tableView 部分中自定义单元格中的标签

[英]Swift: How to access a label in a custom cell within a certain tableView section

我有一个自定义UITableViewCell和一个名为CellLabelUILabel 我希望能够在某个tableView section例如第 3 tableView section访问此标签,并为其提供一个字符串以在不使用数组和arrayName[indexPath.section]

您可以在TableView cellForRowAtIndexPath覆盖中捕获它

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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM