How would I have a button that would add a Section to a UITableView? I know how to do it without adding sections and just having a list but how would you allow the user to add section as well as cells/rows.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest solution is to maintain a parent
NSMutableDictionarydictionary of childrenNSMutableArrayarrays, each child array being its own section of rows.When you click on the button, it adds an empty
NSMutableArraychild to the parent dictionary. The key will be the section index or name. The value will be the child array. You then fill the empty child array with your row objects.Make sure you adjust your delegate methods to reflect the size and content of the parent dictionary and children arrays.