[ad_1]
I am engaged on a mission that should show two desk views without delay that every draw from their very own class, however it doesn’t matter what I attempt, I am unable to get subtitles to show. The desk view cells are formatted to subtitle, and it acknowledges detailed textual content labels, nevertheless it simply shows solely the principle textual content, or simply an empty cell.
——-main story board——-
import UIKit
class MainViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableViewOne: UITableView!
@IBOutlet weak var eraserSwitch: UISwitch!
@IBOutlet weak var tableViewTwo: UITableView!
var topShelf: [Top] = []
var bottomShelf: [Bottom] = []
//var topShelf = ["Milk", "Eggs", "Yogurt"]
//var bottomShelf = ["Lettuce", "Carrots", "Onions"]
override func viewDidLoad() {
tremendous.viewDidLoad()
topShelf.append(T1)
topShelf.append(T2)
bottomShelf.append(B1)
bottomShelf.append(B2)
// Do any further setup after loading the view.
tableViewOne.register(UITableViewCell.self, forCellReuseIdentifier: "cellIDOne")
tableViewOne.delegate = self
tableViewOne.dataSource = self
tableViewTwo.register(UITableViewCell.self, forCellReuseIdentifier: "cellIDTwo")
tableViewTwo.delegate = self
tableViewTwo.dataSource = self
}
@IBAction func switchPressed(_ sender: UISwitch) {
}
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
if tableView == tableViewOne {
return topShelf.rely
}
return bottomShelf.rely
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == tableViewOne {
let cell = tableViewOne.dequeueReusableCell(withIdentifier: "cellIDOne", for: indexPath)
// cell.textLabel?.textual content = topShelf[indexPath.row].description
cell.textLabel?.textual content = topShelf[indexPath.row].merchandise
//cell.textLabel?.textual content = "a"
// cell.detailTextLabel?.textual content = topShelf[indexPath.row].experationDate
//cell.detailTextLabel?.textual content = "a"
cell.detailTextLabel?.textual content = "v"
//print(topShelf[indexPath.row].experationDate)
return cell
} else {
let cell = tableViewTwo.dequeueReusableCell(withIdentifier: "cellIDTwo", for: indexPath)
// cell.textLabel?.textual content = bottomShelf[indexPath.row]
cell.textLabel?.textual content = bottomShelf[indexPath.row].merchandise
cell.detailTextLabel?.textual content = bottomShelf[indexPath.row].experationDate
//print(bottomShelf[indexPath.row].experationDate)
//USE THIS CODE AS A SKELETON FOR ADDING, ERASING, AND MARKING
// if playlist[indexPath.row].Favourite == true {
// cell.detailTextLabel?.textual content = "(playlist[indexPath.row].artistName) ♥"
// } else {
// cell.detailTextLabel?.textual content = "(playlist[indexPath.row].artistName) (playlist[indexPath.row].playCount)"
// }
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView == tableViewOne {
// first desk clicked, use for eraser
tableViewOne.deselectRow(at: indexPath, animated: true)
print("clickOne")
} else {
// you clicked the second desk
tableViewTwo.deselectRow(at: indexPath, animated: true)
print("clickTwo")
}
}
——-Class——-
import Basis
class Prime {
var merchandise: String
var retrievalDate: String
var experationDate: String
init(merchandise: String, retrievalDate: String, experationDate: String) {
self.merchandise = merchandise
self.retrievalDate = retrievalDate
self.experationDate = experationDate
}
}
class Backside {
var merchandise: String
var retrievalDate: String
var experationDate: String
init(merchandise: String, retrievalDate: String, experationDate: String) {
self.merchandise = merchandise
self.retrievalDate = retrievalDate
self.experationDate = experationDate
}
}
let T1 = Prime(merchandise: "Milk", retrievalDate: "10/11/22", experationDate: "10/22/22")
let T2 = Prime(merchandise: "Yogurt", retrievalDate: "10/11/22", experationDate: "10/20/22")
let B1 = Backside(merchandise: "Carrots", retrievalDate: "10/11/22", experationDate: "11/1/22")
let B2 = Backside(merchandise: "Lettuce", retrievalDate: "10/11/22", experationDate: "12/3/22")
[ad_2]
