首页 > 解决方案 > 主故事板和模拟器显示不同的视图

问题描述

这是主故事板的屏幕截图:而不是主故事板屏幕模拟器显示了一个表格视图,其中列出了一堆名称图像和评论部分是不可见的

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
    }


标签: iosswiftuitableview

解决方案


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

以编程方式:

myTableView.dataSource = self
myTableView.delegate = self

或来自 IB:

在此处输入图像描述


推荐阅读