how to create Expandable Table view like Tree Structure in ios
try this :-
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];
}
}
there is UITreeView example at github UITreeView