2010-07-02 75 views
0

我試圖在編輯UITableView時更改自定義UITableViewCell內容(即圖像,按鈕和標籤)的縮進。iPhone - 在編輯時更改單元格的縮進行

我試圖改變細胞的壓痕寬度和水平這樣

[cellToCustomize setIndentationLevel:1]; 
[cellToCustomize setIndentationWidth:20]; 

,並花了我無處。

我還實施了

-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath 

功能。

再次,沒有。

我想增加縮進級別,比方說...加倍。

有人知道該怎麼做嗎?

謝謝!

+0

您是否曾經找到過解決方案?我已經問過類似的問題[這裏](http://stackoverflow.com/questions/5713192/how-can-i-change-the-amount-of-indentation-on-my-custom-uitableviewcell-while-edi) 。 – 2011-04-19 07:51:42

回答

0

您是否重新加載了單元格?請參閱UITableView的文檔中的以下方法:

- (void)reloadData 
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 
+0

Iup,我重新加載了一切重新加載... – camilo 2010-07-02 17:51:43

1

我是有壓痕不顯示爲編輯模式的問題,但我想通了,我已經添加子視圖細胞,而不是cell.contentView - 所有組件應添加爲cell.contentView的子視圖

0
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    arraylist = [[NSMutableArray alloc]init]; 
    array5 = [[NSMutableArray alloc]init]; 
    array1 = [[NSMutableArray alloc]init]; 
    objects = @[@"Medical Services In Chicago",@"Medical Services On Campus"]; 
    arrObjectValueChicago = @[@"Ronald McDonald® Children's Hospital of Loyola",@"Burn Centers",@"Gottlieb Hospitals"]; 
    array3 = [[NSMutableArray alloc]init ]; 
    for(int i = 0; i<[arrObjectValueChicago count];i++){ 
      dictList3 = [[NSDictionary alloc]initWithObjectsAndKeys:@"2",@"level",[arrObjectValueChicago objectAtIndex:i],@"name", nil]; 
     [array3 addObject:dictList3]; 
    } 





    NSDictionary *dictList2 = [[NSDictionary alloc]initWithObjectsAndKeys:@"Hospitals",@"name",@"1",@"level",array3,@"Objects",nil]; 

     NSMutableArray *array2 = [[NSMutableArray alloc]initWithObjects:dictList2, nil]; 
    for (int i =0; i<[objects count]; i++) { 
     dictionary =[[NSDictionary alloc]initWithObjectsAndKeys:[objects objectAtIndex:i],@"name",@"0",@"level",array2,@"Objects", nil]; 
      [array1 addObject:dictionary]; 

    } 


// arrObjectValueCampus = @[@"Cardinal Bernardin Cancer Center1",@"Center for Heart & Vascular Medicine2"]; 
// level = @[@"0",@"1",@"2",@"3"]; 

//  NSDictionary *dictList2 = [[NSDictionary alloc]initWithObjectsAndKeys:@"Hospitals",@"name",@"1",@"level",dictList3,@"Objects",nil]; 
// NSDictionary *dictList1 = [[NSDictionary alloc]initWithObjectsAndKeys:@"0",@"level",@"Medical Services In Chicago",@"name",dictList2,@"Objects",nil]; 
    dictList = [[NSDictionary alloc]initWithObjectsAndKeys:array1,@"Objects", nil]; 

    NSLog(@"Dictionary :: %@",dictList); 
    // [arraylist addObject:[dictList valueForKey:@"Objects"]]; 
    arrayOriginal = [dictList valueForKey:@"Objects"]; 
    [arraylist addObjectsFromArray:arrayOriginal]; 
     } 


- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 
#pragma mark - TableView 
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [arraylist count]; 
} 
-(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] ; 
    } 
    cell.textLabel.text = [[arraylist objectAtIndex:indexPath.row]valueForKey:@"name"]; 
    NSLog(@"Label :: %@",cell.textLabel.text); 
    [cell setIndentationLevel:[[[arraylist objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]]; 

      return cell; 


} 


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSDictionary *d = [arraylist objectAtIndex:indexPath.row]; 
    if ([d valueForKey:@"Objects"]) { 
     NSArray *ar = [d valueForKey:@"Objects"]; 
     BOOL isAlreadyInserted = NO; 
     for(NSDictionary *dInner in ar){ 
      NSInteger index=[arraylist 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]]; 
       [arraylist insertObject:dInner atIndex:count++]; 
      } 
      [tableView insertRowsAtIndexPaths:arCells withRowAnimation:UITableViewRowAnimationBottom]; 
     } 

    } 

} 
#pragma mark - TableAnimation 
-(void)miniMizeThisRows:(NSArray*)ar 
{ 
    for(NSDictionary *dInner in ar) { 
     NSUInteger indexToRemove=[arraylist indexOfObjectIdenticalTo:dInner]; 
     NSArray *arInner=[dInner valueForKey:@"Objects"]; 
     if(arInner && [arInner count]>0){ 
      [self miniMizeThisRows:arInner]; 
     } 

     if([arraylist indexOfObjectIdenticalTo:dInner]!=NSNotFound) { 
      [arraylist removeObjectIdenticalTo:dInner]; 
      [tblist deleteRowsAtIndexPaths:[NSArray arrayWithObject: 
                [NSIndexPath indexPathForRow:indexToRemove inSection:0]] 
            withRowAnimation:UITableViewRowAnimationBottom]; 
     } 
    } 

} 
@end 
相關問題