我创建了这样一个数组:返回标题从标题从阵列部分,其动态
var PropertiesForSectionFromModel :[String] = [String]()
和映射数组这个
override func viewDidLoad() {
super.viewDidLoad()
self.loadData()
}
func loadData()
{ //Here is a Api call and i have successfully called it.
self.PropertiesForSectionFromModel = Array(self.DataSource.map({
(item) -> String in item.labelText
}))
self.tableView.reloadData()
print(self.PropertiesForSectionFromModel)
}
}
}
在这里我得到的打印(自.PropertiesForSectionFromModel) [“名字”,“姓氏”,“出生日期”,“电子邮件”]。这里有四个项目,所以现在应该有四个部分。这些部分本质上是动态的。它可以有更多的部分根据中的项目。PropertiesForSectionFromModel
现在我想将它们设置为titleForHeaderInSection。我曾经做过这样的: `
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return self.PropertiesForSectionFromModel[section]
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return self.PropertiesForSectionFromModel.count
}
`但标题是不是被人displayed..Can帮我为什么不显示??
你迅速上3个工作? –
不是它的2不是3. – Sam
你能调试和检查你在numberOfSectionsInTableView中获得什么样的计数值吗? –