Jeppe Christensen Jeppe Christensen - 1 month ago 4
Swift Question

detailTextLabel doesn't show

i have a function in which i want a big text label and two smaller text label.
The function takes data from a database, and puts them repeatingly into my 3 textlabels.
However, only my default textlabel is visible, Both detailTextLabels doesn't show.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Retrieve cell
let cellIdentifier: String = "BasicCell"
let myCell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
// Get the location to be shown
let item: Parsexml = feedItems[indexPath.row] as! Parsexml
// Get references to labels of cell
print(item)
myCell.textLabel!.text = item.name! + " | " + item.address! + " " + item.nr!
myCell.detailTextLabel?.text = "City: " + item.city!
myCell.detailTextLabel?.text = "category: " + item.category!
//Label styling
myCell.textLabel?.textColor = UIColor(white: 1, alpha: 1)
myCell.textLabel?.font = UIFont(name: "HelveticaNeue-Bold", size: 12)
return myCell
}


How do i get my detail text labels to show in swift 3?

SMi SMi
Answer

That means you have custom cell which has 3 UILables? if so this line should be like this

 let myCell: YouCustomCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!

Then you can use

myCell.1stLable.text = item.name! + " | " + item.address! + " " + item.nr!
myCell.2ndLable.text = "City: " + item.city!
myCell.3rdLable.text = "category: " + item.category!

You must set the cell identifier in storyboard.