我的Popover Controller弹出一个空白的TableView,我不知道为什么。我试图改变单元格和视图的颜色,当我单击弹出窗口时,这似乎不会显示出来。Popover tableview控制器没有显示Data Swift
这里是启动酥料饼代码:
@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
}
这是我为我的泰伯维控制器代码,我曾经尝试过做一个普通视图控制器把一个的tableview上的另一种方法但它产生了相同的结果。 进口的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
}
}
而且是在故事板tableviewcontroller设置为TableViewController。
更新: 我已经改变了部分的数量上tableviewcontroller 1,现在我的应用程序崩溃说致命错误:意外发现零而展开的可选值 (LLDB) 突出
let cell = tableiViewOne.dequeueReusableCell(withIdentifier: "myCell", for: indexPath) as! PopOverTableViewCell
故事板上的单元格名称相同,并且设置为相同的类别
我这样做,而现在它说意外地发现零而展开的可选值彰显我让电池= –
你设置你的tableViewCell在你的故事板'PopOverTableViewCell'? –
在故事板单元中的重用标识符中分配“myCell” –