var QuestionID = [String]()
var Questions = [String]()
var AnswersID = [[String]]()
var AnswersArray = [[String]]()
var AnswerType = [String]()
func tableView(_ tableView: UITableView, cellForRowAt indexPath:
IndexPath) -> UITableViewCell{
let cell =
tblQuickQuestions.dequeueReusableCell(withIdentifier:
"idQuickQuestionsTableViewCell", for: indexPath) as!
QuickQuestionsTableViewCell
cell.backgroundColor = UIColor.white
cell.selectionStyle = .none
cell.lblRadio!.text = AnswersArray[indexPath.sections]
[indexPath.rows]
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection
section: Int) -> Int{
return AnswersArray[section].count
}
/******************************** ************************************************** ***********/ 我的數組值:如何將多維數組值分配給Tableview單元格swift 3
問題ID:[ 「2」, 「3」, 「4」, 「5」, 「6」]
問題:[「地板如何?」,「測試問題???」,「什麼是你的日期」,「測試問題」,「你好嗎?」]
答案類型:[ 「複選框」 ,「複選框」,「下拉菜單」,「下拉菜單」,「單選按鈕」]
回答ID:[[「3」],[「5」],[「6」,「7」 ,「」8「],[」9「],[」10「,」11「,」12「]]
AnswersArray:[[」test「],[」ans「], ,「7月1日」,「15aug」],[「lklklk」],[「aa」,「bb」,「cc」]]
我想實現一個問題,選擇,可以是單選按鈕,複選框或列表類型。我已經實現了二維數組,例如:Answers [[「1」,「2」,「3」],[「1」],[「1」,「2」,「3」,「4」,「 5" ]]。第一個內部數組表示第一個問題的答案,第二個問題的第二個內部數組等等。以及諸如以下問題:問題[「問題1」,「問題2」,「問題3」]。現在我想將這些值分配給表格視圖單元格中的標籤,並希望在下一個按鈕單擊時顯示下一個問題和答案。
如果你也可以分享你的代碼來展示你的嘗試,或者知道你錯在哪裏,會更好。 – Sneha
優化您的問題以確切需要@Bipin Tamkhane –
我只想一次顯示單個問題,並有多個選擇爲該問題提供答案並在下一次點擊時顯示下一個問題答案 –