How to create an extensible table view like Tree Structure in ios

Hello everyone. I need an extensible table view for my data. Is it possible to create my data in the View.In table, each of which has different children, below is my data.

-A1 -A1.1 -A1.1.1 A1.1.1.1 +B1 +C1 +D1 ---------------------- +A1 -B1 +B1.1 +C1 +D1 ----------------------- +A1 +B1 +C1 -D1 +D1.1 -D1.2 +D1.2.1 +D1.2.2 +D1.3 

Help me in advance

+9
ios objective-c uitableview swift expandablelistview
source share
4 answers
+13
source share

try the following: -

  NSMutableIndexSet *expandedSections; @property (strong, nonatomic) NSIndexPath *expandedIndexPath; - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { return 100; } else { return 30; } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { [tableView beginUpdates]; self.expandedIndexPath = nil; [tableView endUpdates]; } else{ self.expandedIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]; [tableView beginUpdates]; if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { self.expandedIndexPath = indexPath; } else { self.expandedIndexPath = nil; } [tableView endUpdates]; } } 
+2
source share

there is an example of a UITreeView in github UITreeView

+1
source share

I have a Swift Tree View example on github https://github.com/sstahurski/SRSTreeView

0
source share

All Articles