在 cellForRowAtIndexPath 方法中,我创建了一个自定义单元格。该单元格有一个标签来显示项目名称。为标签赋值后,打印时显示 nil 值。因此该标签无法显示在表格视图中。
let cell = self.LeadsListTable.dequeueReusableCell(withIdentifier:"LeadsID", for: indexPath) as! LeadsCell
if let leadsDict: NSDictionary = self.leadsArray[indexPath.row] as? NSDictionary
{
cell.project_title?.text = (leadsDict.object(forKey: "project_title") as! String)
}
这种方式我用来显示标签的值
po print(cell.project_title?.text) (or) print(cell.project_title?.text)