Reputation: 289
I am trying to implement a UITableView with the following structure :
struct DataArray {
var mainsection : String
var titlecontent : String
var contentsection : [(question : String, answer : String)] = [(String, String)]()
}
var dataArray = [DataArrayArray]()
dataArray = [DataArray(mainsection : "Section 1","Section Title 1",[("question1","answer1"),("question2","answer2")]),
DataArray(mainsection : "Section 2","Section Title 2",[("question1","answer1"),("question2","answer2")])]
The TableView should look like this and when the user clicks Section 1 ->expand the subsection (SectionTitle1 & SectionTitle2); when user clicks SectionTitle1 -> expand the subsection(Question1 & Question 2); When the user again clicks Question1 -> show the answer :
Section 1
Section Title 1
Question 1
Question 2
Section 2
Section Title 1
Question 1
Question 2
Can anyone help me with this or any other solution to solve this?
Upvotes: 0
Views: 715
Reputation: 738
This type of TableView is generally called Accordion TableView. If you run google search for this you will find a lot of tutorials and sample codes. 2 links are mentioned below
Upvotes: 1