我要顯示其數據放在桌子上,這Perticuler數據具有子數據的iOS:UITableView的表數據沒有出現在以子類別:iPhone
對於防爆。
甲組
1.1 的名稱列表
B組
2.1 的名稱列表
體育2.2 列表
Thx提前(^_^)
我要顯示其數據放在桌子上,這Perticuler數據具有子數據的iOS:UITableView的表數據沒有出現在以子類別:iPhone
對於防爆。
甲組
1.1 的名稱列表
B組
2.1 的名稱列表
體育2.2 列表
Thx提前(^_^)
您需要實現MultiLevel UITableView很好的教程,這要歸功於Sagar
// Customize the appearance of table view cells.
- (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] autorelease];
}
cell.textLabel.text=[[self.arForTable objectAtIndex:indexPath.row] valueForKey:@"name"];
[cell setIndentationLevel:[[[self.arForTable objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSDictionary *d=[self.arForTable objectAtIndex:indexPath.row];
if([d valueForKey:@"Objects"]) {
NSArray *ar=[d valueForKey:@"Objects"];
BOOL isAlreadyInserted=NO;
for(NSDictionary *dInner in ar){
NSInteger index=[self.arForTable indexOfObjectIdenticalTo:dInner];
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:0]]
withRowAnimation:UITableViewRowAnimationRight];
}
}
}
是啊...我試着在我的項目Sagar教程中的這個示例代碼是最好的.... –
Thx我有相同的代碼,但是當我用這個在我的項目中所有表格單元格都在直線..... Wht我現在應該做什麼請 –
@RahulSharma你試過[示例代碼](http://sugartin.info/wp-content/uploads/2015/11/cellMaxMinDemo-Updated.zip)它工作得很好我已經在我身邊進行了測試,也花了一些時間來理解這個例子,並嘗試在你的項目中遵循相同的原則,我相信你會得到它的工作。 – swiftBoy
嘗試使用'contentInset'爲你的細胞。 – zcui93