在编辑 tableview 单元格时,单元格不是在编辑新单元格而是在 tableview 中添加为什么?很快

问题描述

我有一个 JSON API 用于在 tableview 中添加服务并编辑服务..在 API 参数中,如果 service_id 为空,那么我需要在 tableview 中添加服务..如果 service_id 是某个值,那么我需要编辑值并提交,然后编辑后的值应显示在同一个单元格中,哪些单元格 service_id 添加在参数中

为此,我在 PostServiceVC 中有以下代码用于在 tableview 中添加单元格:在 PageContentViewController 中,我显示所有添加的单元格..在这里,如果我单击编辑,则应编辑相应的单元格。 . 但是在编辑时也会添加新单元格.. 为什么?..

class PostServiceVC: UIViewController,UITextViewDelegate {

 @IBAction func submitRequestBtn(_ sender: TransitionButton) {
    
    if categoryTextfield.text?.trim() == ""{
        return self.view.maketoast(CommonMessages.validationError(of: .category))
    }
    if requestTitleTextfield.text?.trim() == ""{
        return self.view.maketoast(CommonMessages.validationError(of: .title))
    }
            
    let parameters = ["service_id" : servID as? String,"title" : requestTitleTextfield.text!,"category" : categoryTextfield.text!]
    
    APIReqeustManager.sharedInstance.serviceCall(param: parameters as [String : Any],method: .post,loaderNeed: false,loadingButton: sender,needViewHideShowAfterLoading: nil,vc: self,url: CommonUrl.post_service_request,isTokenNeeded: true,isErrorAlertNeeded: true,isSuccessAlertNeeded: true,actionErrorOrSuccess: nil,fromLoginPageCallBack: nil) { [weak self] (resp) in
        if let code = ((resp.dict?["result"] as? [String : Any])){
            let success = code["status"] as? [String : Any]
            let message = success?["message"] as? String
            if message == "Success"{
                let vc = Helper.getVcObject(vcName: .PageContentViewController,StoryBoardName: .Requests) as! PageContentViewController
                self?.checkAndPushPop(vc,navigationController: self?.navigationController)
            }
        }else{
            self?.view.maketoast(CommonMessages.somethingWentWrong)
        }
        self?.serviceData = PostServiceReqBaseModel(dictionary: resp.responseDict as? NSDictionary ?? NSDictionary())

    }
   }

上面最初的 service_id 是 nil,所以我可以在 PageContentViewController 的 tableview 中添加单元格。如下图

PostServiceVC

PageContentViewController 中的代码:像这样我发送 service_id 值..但是如果我在 PostServiceVC 中编辑文本并提交然后添加新单元格,为什么?我需要编辑相同的单元格..怎么做?

 let vc = Helper.getVcObject(vcName: .PostServiceRequestVC,StoryBoardName: .Requests) as! PostServiceRequestVC
 vc.servID = servId
self.checkAndPushPop(vc,navigationController: self.navigationController)

请帮忙编辑tableview单元格

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)