큰 텍스트 레이블과 2 개의 작은 텍스트 레이블이 필요한 기능이 있습니다. 이 함수는 데이터베이스에서 데이터를 가져와 반복적으로 내 3 개의 텍스트 레이블에 넣습니다. 그러나 내 기본 textlabel 만 표시됩니다. 두 detailTextLabels는 표시되지 않습니다.detailTextLabel이 표시되지 않습니다
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
}
스위프트 3에 내 세부 텍스트 레이블을 표시하려면 어떻게해야합니까?
어쩌면 당신은 당신의 셀에'.addSubview'를 잊었을까요? –
셀이 사용자 정의 셀인 것처럼 보이기 때문에이 셀을 참조하는 커스텀 클래스를 생성해야합니다 ('UITableViewCell' of-course를 하위 클래스 화하여). 그런 다음 해당 클래스를 사용하여 사용자 정의 셀에 액세스하십시오. – rptwsthi