하나의 git 허브 자습서에서 plist 값을 사용하여 테이블 뷰를 확장 및 축소합니다. 그 자습서에서 내가 행을 누를 때 확장되고 있습니다. 동일한 행을 누르면 다시 문제가 없습니다. 그러나 내가 원하는 것은 행을 누르면 다른 행이 열리게 될 것이라고 기대할 때입니다. 그래서 어느 누구도 나에게 약간의 아이디어를 줄 수 있습니다. 확대/축소 ios에서 선택된 다른 행을 셀 축소 행
이
는 한 번에 정확히 하나의 셀을 확장하려는 의미 확장하고- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSDictionary *d=[self.arForTable objectAtIndex:indexPath.row];
NSLog(@"%@",d);
if([d valueForKey:@"Objects"]) {
NSArray *ar=[d valueForKey:@"Objects"];
NSLog(@"%@",ar);
BOOL isAlreadyInserted=NO;
for(NSDictionary *dInner in ar){
NSInteger index=[self.arForTable indexOfObjectIdenticalTo:dInner];
NSLog(@"%ld",(long)index);
isAlreadyInserted=(index>0 && index!=NSIntegerMax);
if(isAlreadyInserted) break;
}
if(isAlreadyInserted)
{
[self miniMizeThisRows:ar];
}
else
{
NSUInteger count=indexPath.row+1;
NSMutableArray *arCells=[NSMutableArray array];
for(NSDictionary *dInner in ar) {
[arCells addObject:[NSIndexPath indexPathForRow:count inSection:0]];
[self.arForTable insertObject:dInner atIndex:count++];
}
[tableView insertRowsAtIndexPaths:arCells withRowAnimation:UITableViewRowAnimationLeft];
}
}
}
-(void)miniMizeThisRows:(NSArray*)ar{
for(NSDictionary *dInner in ar) {
NSUInteger indexToRemove=[self.arForTable indexOfObjectIdenticalTo:dInner];
NSArray *arInner=[dInner valueForKey:@"Objects"];
if(arInner && [arInner count]>0){
[self miniMizeThisRows:arInner];
}
if([self.arForTable indexOfObjectIdenticalTo:dInner]!=NSNotFound)
{
[self.arForTable removeObjectIdenticalTo:dInner];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:
[NSIndexPath indexPathForRow:indexToRemove inSection:1]
]
withRowAnimation:UITableViewRowAnimationRight];
}
}
}
해결책을 찾았습니까? 나는 또한 같은 해결책을 찾고있다 ... –
Fahim 형제는 이것에 대한 해결책이 있나? – user3182143