[英]Swift: How to access a label in a custom cell within a certain tableView section
我有一个自定义UITableViewCell
和一个名为CellLabel
的UILabel
。 我希望能够在某个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.