2015-09-03 36 views
0

我正在使用SWRevealViewController。 enter image description here滑出側欄與子類別

這些是表視圖中的一些行。每一行打開一個新的視圖。 現在我想在服務點擊時顯示一些子類別/行,反之亦然。 子類別將像設計,開發,應用等 和這個子類別的每一個打開不同的看法。 我只用了1節。有任何想法嗎?

回答

1

您可以使用包含的UITableView的子類 這裏UIPopoverContoller是鏈接UIPopover https://github.com/alvises/FPPopover 至於UIPopover是爲iPad所以在iphone你也會有上述進口第三方庫提。

+0

很抱歉,但我不想用這種方式和風格。 –

0

使用以下步驟來實現擴張的細胞

- (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; 

}

這是該方法的TableView DidSelectRow方法展開和摺疊行

- (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]; 
    } 
} 
} 
+0

它顯示2錯誤。沒有可見的insertObject,removeObjectIdenticalTo接口。如何解決這些問題 –

+0

使所有數組成爲全局變量,並在變量 – Ammar

+0

之前添加@property(nonatomic,strong)。仍然收到錯誤。 –