代码之家  ›  专栏  ›  技术社区  ›  Kevin

Swift 3.0使用表格视图显示和添加注释

  •  0
  • Kevin  · 技术社区  · 8 年前

    var comments = ["I like this item","Where did you get this?", "I can't believe you found this!", "Hello", "Yay"]  
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    
        return comments.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CustomCell
    
    
        cell.commentView.text = dataName[indexPath.row]
        cell.commentView.textColor = UIColor.lightGray
        cell.commentView.isEditable = false
        cell.commentView.isScrollEnabled = false
    
    
        return cell
    }
    
    2 回复  |  直到 8 年前
        1
  •  2
  •   OverD    8 年前

        2
  •  0
  •   matt    8 年前

    你已经有了一个叫做 "Cell" "Comment" . 现在,您有了两个具有两个不同标识符的单元原型。如果您在最后一排,请询问 您的手机中的手机原型 dequeue