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

标签 ios swift uitableview

我有一个自定义 UITableViewCell 和一个名为 CellLabelUILabel。我希望能够在某个 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/

相关文章:

ios - 二元运算符 '<' 不能应用于类型 'Double?' 和 'Double' 的操作数

swift - 在alamofire管理器类swift中添加公钥固定

ios - 如果返回空数组,UITableView editActionsForRowAtIndexPath 将停止工作

ios - 如何根据从数据库中提取的数据使 UITableView 中正确的自定义单元格出队?

ios - swift : Error when saving to core data context

ios - 当应用程序在后台时从默认通知中心接收通知

android - 制作一款在 Facebook 上运行并作为智能手机应用程序运行的游戏

json - 使用 Codable 协议(protocol)解析包含日期作为键的 Stock API

objective-c - 动画 contentInset 到 UITableView 也会动画行的 subview 的框架

ios - xcodebuild ios 导出存档在成功构建时失败