My Popover Controller is popping up with a blank TableView and I have no idea why. I have tried changing the color of the cell and view and this doesn't even seem to show up when I click the popover.
Here is the code for initiating the popover:
@IBAction func popOverButton(_ sender: UIButton)
{
let controller = TableViewController()
controller.modalPresentationStyle = .popover
// configure the Popover presentation controller
let popController: UIPopoverPresentationController? = controller.popoverPresentationController
popController?.permittedArrowDirections = [.down]
popController?.delegate = self
popController?.sourceView = sender
popController?.sourceRect = sender.bounds
popController?.backgroundColor = .white
self.parent?.present(controller, animated: true, completion: { })
}
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle
{
return UIModalPresentationStyle.none
}
Here is my code for my Tableview controller, I had tried the other method before of making a regular ViewController putting a tableview on to it but that yielded the same results. import UIKit
class TableViewController: UITableViewController {
var categories = PTTableView().titles
//PTTableview.titles is a populated array from another viewcontroller and it is not empty
@IBOutlet var tableiViewOne: UITableView!
override func viewDidLoad()
{
super.viewDidLoad()
}
override func numberOfSections(in tableView: UITableView) -> Int
{
return 0
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return categories.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableiViewOne.dequeueReusableCell(withIdentifier: "myCell", for: indexPath) as! PopOverTableViewCell
cell.cellLabelOne.text = categories[indexPath.row]
return cell
}
}
And yes the tableviewcontroller on the storyboard is set to the TableViewController.
UPDATE: I Have Changed the number of sections on the tableviewcontroller to 1 and now my app is crashing saying fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) Highlighting
let cell = tableiViewOne.dequeueReusableCell(withIdentifier: "myCell", for: indexPath) as! PopOverTableViewCell
I have the same cell name on the storyboard and It is set to the same class