var leadername = ["1","2","3","4"]
var districts = ["Delhi","Kerala"]
override func viewDidLoad() {
leadTableSetup()
super.viewDidLoad()
}
func leadTableSetup(){
LeadTableView.delegate = self
LeadTableView.dataSource = self
self.LeadTableView.register(UINib(nibName: "LeaderBoardTableViewCell", bundle: nil), forCellReuseIdentifier: "leadCell")
}
func numberOfSections(in tableView: UITableView) -> Int {
return 5
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 14
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "leadCell") as! LeaderBoardTableViewCell
// Set text from the data model
cell.areaLbl.text = districts[indexPath.row]
cell.leaderNameLbl.text = leadername[indexPath.row]
return cell
}
我已经声明了两个字符串,我需要在我创建的自定义集合视图单元格中的标签中显示这些字符串。我怎样才能做到这一点?我需要在一个标签中显示“leadername”字符串,在另一个标签中显示“区域”标签。如何在Swift ios中的自定义TableView Cell中将多个字符串值显示为多个标签?
你可以显示'LeaderBoardTableViewCell' –
[样本](https://www.credera.com/wp-content/uploads/2015/08/Custom-Collection-Views-1.png)我认为你需要输出一些东西喜欢这个。每个单元格中都有两个标签,但其中的值与数组值相符。对? @Rakesh –
@TinuDahiya。正确 – Rakesh