2009-10-03 71 views
1

我几乎添加了很多我的CustomCell,它的工作很好。 然而,那里有一件事我不能工作了..自定义UITableViewCell,触摸扩展,包括uitextfield

我的要求是,对于分组的TableView,在攻单的UITableViewCell,它应该低于扩大,还挺有生命的和下方延伸,并显示在该单元格的更多信息。

在点击一个已经展开的单元格时,它应该回到“正常”单元格状态。

任何方向,我可以在这里将是巨大的..

也,看看下面的代码,有一个电池变量,并我添加图像到cell.acccessoryVIew,有一些例子,他们在内写入添加图像的代码(if(cell == nil){})。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *kCustomCellID = @"MyCellDetailSym"; 
    CustomCell *cell = (CustomCell *)[self.tableView dequeueReusableCellWithIdentifier:kCustomCellID]; 
    if (cell == nil) 
    { 
     cell = (CustomCell *)[[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCustomCellID] autorelease]; 

    } 
    cell.checkNeeded = YES; 
    appdelegate *appDelegate = (appdelegate *)[[UIApplication sharedApplication] delegate]; 
    customClass *nSym = (customClass *)[ArrayCache objectAtIndex:indexPath.row]; 
    if([appDelegate.sMap containsObject:[NSString stringWithFormat:@"%d",[nSym pKey]]]) { cell.checked=YES; } else cell.checked = NO; 
    if([appDelegate.favoriteSymArray containsObject:[NSString stringWithFormat:@"%d",[nSym pKey]]]) { cell.starred=YES; } else cell.starred = NO; 
    cell.title = nSym.txtSym; 

    UIImage *starredImage = [UIImage imageNamed:@"Star_list_active.png"]; 
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
    CGRect frame = CGRectMake(0.0, 0.0, starredImage.size.width + 5 , starredImage.size.height + 5); 
    button.frame = frame; 

    UIImage *image = (cell.starred) ? starredImage: [UIImage imageNamed:@"Star_list_inactive.png"]; 
    //UIImage *newImage = [image stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0]; 
    [button setEnabled:YES]; 
    [button setBackgroundImage:image forState:UIControlStateNormal]; 
    [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 
    button.backgroundColor = [UIColor clearColor]; 
    cell.accessoryView = button; 

    return cell; 

} 

谢谢你们

回答

0

我这样做的方式是调用- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation指定下一行作为插入行,并与UITableViewRowAnimationTop动画创造的下拉作用。要完成细胞“扩张”的错觉,请确保您的separatorColor与您的背景相匹配。

不要尝试调用委托方法来调整行高度;据我所知,它不会生成动画。