如何在 iOS Objective-C 的 UITableView 中创建类别和子类别选择

问题描述:

我想在 UITableView 中使用 iOS 的 Objective-C 创建一个带有类别和子类别选择的表格视图,但我不知道要搜索什么以及从哪里开始.类别和子类别的内容是动态的,可以是一个或多个,然后由Web服务结果决定.并且所有类别都应立即折叠.它应该是这样的.

I want to create a table view with category and subcategory selection in UITableView with Objective-C for iOS but I do't know what to search and from were to start. The content of the category and subcategory are dynamic it can be one or more then it will be decided by web service result. and all category should be collapse on tap. It should look like this.

任何建议和帮助将不胜感激

Any suggestion and help will be appreciated

编辑 #1

我尝试了一些东西但不能正常工作这里是我尝试过的代码.兴趣(类别和子类别)

I have tried something but not working fine here is the code for what i have tried yet. Interest (Category and Subcategory)

我认为你应该创建一个带有 'parentCategory' 属性的 CategoryViewController.

I think you should create a CategoryViewController with a 'parentCategory' property.

最初此属性为空,它将加载您的所有基本类别.然后,当您选择一个类别(如果它有子类别)时,您将对相同的 CategoryViewController 执行 segue 并设置此 parentCategory 属性.您将使用此属性加载子类别.

Initially this property will be empty and it will load all of your base categories. Then when you select a category if it has children you will perform a segue to the same CategoryViewController and set this parentCategory property. You will use this property to load up the child categories.