UITableViewCell中的UITextView中的文本未显示

时间:2018-02-07 18:59:01

标签: ios swift uitableview

我尝试将一些文本分配给自定义表格单元格中的文本视图,但由于某种原因,文本未显示。我有2个类似的表格单元格,其中1个有图像和文本,另一个只有文本。第一个1没有问题,但在将文本分配给第二个单元格时,它不起作用。

  

主表视图控制器

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let imageCheck = tableData[indexPath.row]["Image"] {
            let cell = tableView.dequeueReusableCell(withIdentifier: "imageNotesData", for: indexPath) as! ImageNotesCell
            cell.notes.text = tableData[indexPath.row]["Notes"] as! String
            guard let imageFirebasePath = tableData[indexPath.row]["Image"] else {
                return cell }
            let pathReference = Storage.storage().reference(withPath: imageFirebasePath as! String)
            pathReference.getData(maxSize: 1 * 1614 * 1614) { data, error in
                if let error = error {
                    print(error)
                } else {
                    let image = UIImage(data: data!)
                    cell.storedImage.image = image
                }
            }
            return cell
        }
        else {
            let cell = tableView.dequeueReusableCell(withIdentifier: "notesData", for: indexPath) as! NotesCell
            let noteString = tableData[indexPath.row]["Notes"] as! String
            print("NS: ",noteString)
            cell.notes.text = tableData[indexPath.row]["Notes"] as! String
            return cell
        }
    }

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(tableData[indexPath.row]["Notes"])
    }
  

ImageNotesCell.swift       导入UIKit

class ImageNotesCell: UITableViewCell {

    @IBOutlet weak var storedImage: UIImageView!
    @IBOutlet weak var notes: UITextView!
}
  

NotesCell.swift

import UIKit

class NotesCell: UITableViewCell {

    @IBOutlet weak var notes: UITextView!
}

在Firebase数据库中,我的示例文本是"自定义伪装成了至高无上的。"当print("NS: ",noteString)投放时,我会NS: The custom disguises a supreme.当我点击该行触发didSelectRowAt时,它会输出Optional(The custom disguises a supreme.)我会检查是否连接了这些插座,但我确定我做到了。不知道问题在哪里。

notesView constraint 1

notesView contraint 2

对于行高

,自定义类notesData的表视图单元格高度为350

0 个答案:

没有答案