主故事板和模拟器显示不同的视图

时间:2020-02-10 11:41:19

标签: ios swift uitableview

这是主故事板的屏幕截图:而不是主故事板屏幕模拟器显示带有一堆名称的表格视图,其中图像和注释部分不可见

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return userEmailArray.count
    }

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! FeedCell

        cell.useremailLabel.text = userEmailArray[indexPath.row]
        cell.likeLabel.text = String(likesArray[indexPath.row])
        cell.commentLabel.text = userCommentArray[indexPath.row]
        cell.userimageView.image = UIImage(named: "selectImage.png")



        return cell
    }


1 个答案:

答案 0 :(得分:0)

您必须将dataSource和委托连接到视图控制器(或用于实现它的处理程序)。

以编程方式:

myTableView.dataSource = self
myTableView.delegate = self

或者从IB:

enter image description here