您好我有一个表与信息从一个JSON的地址,我设法按邻居排序他们按下按钮时,我想创建可扩展的&可折叠部分与邻域相同按钮。从NSMutableArray展开和可折叠的UITableView部分
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] init];
}
NSString *cellName = [[myArray objectAtIndex:indexPath.row] valueForKeyPath:@"name"];
NSString *cellState = [[myArray objectAtIndex:indexPath.row] valueForKeyPath:@"desc"];
NSString *cellTodo = [NSString stringWithFormat:@"%@: %@", cellState, cellName];
[[cell textLabel] setFont:[UIFont systemFontOfSize: 11.0]];
cell.textLabel.text = cellTodo;
return cell;
}
- (IBAction)PorBarrio:(id)sender {
NSSortDescriptor * sortDesc = [[NSSortDescriptor alloc] initWithKey:@"desc" ascending:YES];
[myArray sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];
[myTableView reloadData];
}
检查苹果示例代码[表视图动画和手势(http://developer.apple.com/library/ios /#samplecode/TableViewUpdates/Introduction/Intro.html)可折叠表格视图 –
检查http://stackoverflow.com/questions/15442697/how-to-create-an-accordion-with-uitableview-under-a-uitableview – saturngod
我刚刚开始了一个[GitHub项目](ht tps://github.com/i2097i/SRExpandableTableView)用于iOS可展开的UITableView,称为SRExpandableTableView。我希望它有帮助! – i2097i