ios - Swift/iOS - UITableView 与 UITableViewCell 不填充结果

标签 ios swift sqlite uitableview

enter image description here基本上,我试图用 SQLITE 结果获取我的 TableView,但它根本没有填充。奇怪的是,我编辑了一个 sqlite 示例项目来执行相同的操作,但是是从我的数据库中进行的,并且它有效。

此外,在我的项目中,除了单元名称等之外,它与 SQLITE 示例项目具有完全相同的代码,我可以创建一个警报来显示数组中的结果之一,并且它工作正常。

我不明白为什么它不会填充。

抱歉,如果我不能很好地解释它,但这是我的代码和一个尝试在没有电视结果但有警报的情况下工作的示例。

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return returnedCardNames.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell:CardInfo_Cell = tableView.dequeueReusableCellWithIdentifier("cardCell") as! CardInfo_Cell
    let card_name:CardInfo_Adapter = returnedCardNames.objectAtIndex(indexPath.row) as! CardInfo_Adapter
    cell.card_nameLabel.text = "\(card_name.CardName)"
    return cell
}

override func viewWillAppear(animated: Bool) {
    self.getCardNames()
}

func getCardNames()
{
    returnedCardNames = NSMutableArray()
    returnedCardNames = Card_Adapter.getInstance().getAllSimilarCardNamesByUserEntry("null", passedSetName: "null")
    cardResults.reloadData()

    let card_name:CardInfo_Adapter = returnedCardNames.objectAtIndex(10) as! CardInfo_Adapter
    Util.invokeAlertMethod("Card Results", strBody: card_name.CardName, delegate: nil)
}

enter image description here

最佳答案

我通过在 ViewDidLoad() 中为 UITableView 提供委托(delegate)和数据源的 self 方法来修复此问题。

self.cardResults.delegate = self
self.cardResults.dataSource = self

我使用了另一个 stackoverflow 线程,它提供了答案。 UITableView datasource functions not called (swift)

关于ios - Swift/iOS - UITableView 与 UITableViewCell 不填充结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33425709/

相关文章:

ios - WebSocket网络错误: The operation couldn’t be completed

ios - Swift:多项 for 循环检查数组中的输入值

swift - UITableView CoreData - 排序描​​述符不影响标题

sqlite - 为什么在 SQLite 中使用 TFDQuery 合并两个数据集后数字字段变成 TWideStringField

SQLite where 子句对 TEXT 字段表现奇怪

Java 数据库立即断开连接

objective-c - 在 Objective-C 中删除单元格行

ios - 尽可能压缩UIImage?

ios - 在 Swift 中按名称获取实例变量

ios - 创建具有微妙模糊效果的透明 UIView