【发布时间】:2020-02-17 09:26:17
【问题描述】:
如何提交所有cell values动态
这里是代码。我只是点击了 api,然后我附加了这些值,然后我显示了所有 data。 现在的问题是如何获取所有值的文本字段。
func submitApi(){
SVProgressHUD.show(withStatus: "Loading please wait........")
let url = constatUrl + "url"
print("catagory",url)
Alamofire.request(url, method: .get, parameters:nil, encoding: URLEncoding.default, headers: nil).responseJSON { (response:DataResponse<Any>) in
switch(response.result) {
case .success(_):
SVProgressHUD.dismiss()
if let data = response.result.value{
let json = response.result.value as? [String: Any]
print("theloginAuthValue is ",json!)
let responseStatus = json!["responseStatus"] as! Bool
let responseText = json!["responseText"] as! String
if (responseStatus == true){
self.user_GLosary.removeAll()
self.productLabel.isHidden = false
self.quantyLabel.isHidden = false
self.quntySubmitButton.isHidden = false
let responseData = json!["responseData"] as! [Any]
var index = 0
while index < responseData.count{
let responseArray = responseData[index] as! [String: Any]
let chainId = responseArray["id"] as? String
let chainValue = responseArray["value"] as? String
let folderAppend = FolderGlosaryDetails()
folderAppend.glosaryId = chainId
folderAppend.glosaryName = chainValue
self.user_GLosary.append(folderAppend)
index += 1
}
DispatchQueue.main.async {
self.openingStockTableView.reloadData()
}
}
else if (responseStatus == false){
self.displayAlertMessage(messageToDisplay: responseText)
}
}
break
case .failure(_):
SVProgressHUD.dismiss()
print("faliure",response.result.error!)
self.displayAlertMessage(messageToDisplay: "Something Wrong Please try again")
break
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return user_GLosary.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:"OpeningStockCell",for: indexPath) as! OpeningStockCell
cell.stockLabel.text = user_GLosary[indexPath.row].glosaryName
return cell
}
【问题讨论】:
-
问题不清楚。你所期待的。
-
我希望所有文本字段值都存储在空数组中
-
cell.yourTextField.tag = indexPath.rawcell.yourTextField.delegate = self就是这样!
标签: ios swift xcode uitableview