I have 2 table views in one View Controller. I declare these two tables.
@IBOutlet weak var packTableView: UITableView!
@IBOutlet weak var mediapackTableView: UITableView!
I declare this code in ViewDidLoad.
mediapackTableView.delegate = self
mediapackTableView.dataSource = self
mediapackTableView.register(MediaPackTableViewCell.self, forCellReuseIdentifier: "mediaPackCell")
packTableView.delegate = self
packTableView.dataSource = self
and I also add these following codes.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if(packSegmentedControl.selectedSegmentIndex != 2)
{
debugPrint("This is NOOOOOOOO")
let cell: TableViewCell1 = tableView.dequeueReusableCell(withIdentifier: "packCell", for: indexPath) as! TableViewCell1
cell.lblId.isHidden = true
SwiftLoading().hideLoading()
returnValues = cell
return returnValues
} //segemented control check
else if packSegmentedControl.selectedSegmentIndex == 2 {
debugPrint("This is YESSSSSSSSSSSS")
packTableView.isHidden = true
mediapackTableView.isHidden = false
self.lblPackDescription.text = NSLocalizedString("Media Packs", comment: "")
let cell: TableViewCell2 = tableView.dequeueReusableCell(withIdentifier: "mediaPackCell", for: indexPath) as! TableViewCell2
cell.textLabel?.text = "SOFTWARE"
debugPrint("HELLO")
return returnValues
}
return returnValues
}
I got error when I click on Third Segmented Control.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier mediaPackCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
My reference video is https://www.youtube.com/watch?v=MYJRQyAtQYg
Could anyone help me please?
Looks like there's an issue with the cell identified of mediaPackCell. While it could be a few things related to it - did you set it on the UI?