Ios 无法正确重新加载tableview

Ios 无法正确重新加载tableview,ios,swift,xcode,Ios,Swift,Xcode,我有一个tableview,它是返回问题列表的导航控制器的一部分 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for:indexPath) as! AnswerTableViewCell let d

我有一个tableview,它是返回问题列表的导航控制器的一部分

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for:indexPath) as! AnswerTableViewCell
    let data = quesList[indexPath.row]

    cell.labelName.text = data.sender_name;
    cell.labelQuestion.text = data.text;

    return cell
}

func fetchQues(){
    Ref.queryOrdered(byChild: currentuser).queryEqual(toValue: nil).observe(DataEventType.value, with:{(snapshot)in
        if snapshot.childrenCount>0{
            self.quesList.removeAll()
            for data in snapshot.children.allObjects as![DataSnapshot]{
                let dataObject = data.value as? [String: AnyObject]
                let userid = dataObject?["sender_id"];
                let username = dataObject?["sender_name"];
                let questext = dataObject?["text"];
                let questionid = dataObject?["id"];

                let data = Question(id: questionid as! String, sender_id: userid as! String, sender_name: username as! String, text: questext as! String)

                self.quesList.insert(data, at :0)

            }
            self.AnswerTable.reloadData()
        }
    })
}
然后,我有一个didselectrow函数来切换到这个导航堆栈的VC部分,让用户输入问题的答案

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let data = quesList[indexPath.row]

    questionselect1 = data.text;
    questionid1 = data.id;

    performSegue(withIdentifier: self.questSegue, sender: nil)
}
在用户提交问题的答案后,它会将一个字典添加到问题字典中,并返回到问题列表屏幕。queryorder(bychild:currentuser).queryeuqual(tovalue:nil)将只返回当前用户尚未回答的问题。因此,每当用户回答一个问题时,该问题就会从列表中删除

  @IBAction func submitAnswer(_ sender: Any) {
    if questiontext.text != "" {
        DBProvider.Instance.postAnswers(senderID: userid, senderName: username2, text: questiontext.text!)
        DBProvider.Instance.postAnswered()
        self.questiontext.text = "";
        self.navigationController!.popViewController(animated: true)
        //append data to the current question


    } else {
        alertTheUser(title: "Please Submit A Valid Answer", message: "Question Field Cannot Be Empty");

    }

}
但是,当列表上只有一个问题,并且用户回答了它,然后返回到问题表视图时,最后一个问题不会从列表中删除,因为它已经被回答了

我只需要补充一点,当我完全退出我的应用程序并再次登录时,问题列表是空的,并且会正确刷新,因为所有的问题都已回答

我一直在试图通过更改segueing方法并使用viewwillload或viewdidload重新加载视图来找出为什么会发生这种情况,但它不起作用


希望有人能理解我所说的,并能为我的错误提供答案。

如果不看代码,很难准确地说出来,但这可能是由于没有在某个视图控制器的根UIView上设置背景颜色造成的。

您能共享项目演示链接吗?如果不这样,您能共享代码吗回答.最新问题