如何在uitableview中隐藏特定单元格高度的高度

时间:2013-01-25 06:24:12

标签: ios uitableview

如何在单击按钮时隐藏uitableviewcell中的标签?

我在tableviewcell中有标签和按钮,当我点击那个细胞高度应该减少的细节按钮时,以及应该隐藏细胞标签。

enter code here

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath
   {
   UIWebView *webView=(UIWebView*)[cell.contentView viewWithTag:999+indexPath.row];
    if(webView==nil)
    {

     webView =[[UIWebView alloc]initWithFrame:CGRectMake(100, 50, 700, 100)];
    [webView loadHTMLString:[text_Array objectAtIndex:indexPath.row] baseURL:nil];
    webView.backgroundColor=[UIColor clearColor];
    [cell.contentView addSubview:webView];
    webView.tag=indexPath.row+999;

    int hideWeb=[[webHideArr objectAtIndex:indexPath.row]intValue];
    if(hideWeb==1)
    {
        webView.hidden=YES;
    }
    else           
    {
        webView.hidden=NO;
    }
    }
   }

  -(void)reviewedCustomButtonClicked:(id)sender
   {
int irow=[sender tag]-222;

UITableViewCell *Cell=(UITableViewCell*)[progressTableView cellForRowAtIndexPath:    [NSIndexPath indexPathForRow:irow inSection:0]];

UIWebView *web=(UIWebView*)[Cell.contentView viewWithTag:irow+999];
isCustomReviewed=YES;

[webHideArr removeAllObjects];
for(int h=0;h<[array count];h++)
{
    [webHideArr addObject:@"0"];
}

if([btn currentImage]!=[UIImage imageNamed:@"arrow_up.png"])
{
    [btn setImage:[UIImage imageNamed:@"arrow_up.png"] forState:UIControlStateNormal];
    web.hidden=YES;
     [imgArr replaceObjectAtIndex:irow withObject:@"1"];
    [webHideArr replaceObjectAtIndex:irow withObject:@"1"];

}
else
{
    [btn setImage:[UIImage imageNamed:@"arrow_dwn.png"] forState:UIControlStateNormal];
    web.hidden=NO;
    [imgArr replaceObjectAtIndex:irow withObject:@"0"];
    [webHideArr replaceObjectAtIndex:irow withObject:@"1"];
}

increseCellHeight=[sender tag]-222;
decreaseCellHeight=[sender tag]-222;
[progressTableView reloadData];
 }

       - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
   {
    if(isCustomReviewed==YES)
     { 
         if (indexPath.section == 0 && indexPath.row == increseCellHeight)
        {

            return 150;
        }
        else
        {
            return 50;
        }
    }

1 个答案:

答案 0 :(得分:0)

当您点击更新高度&amp;的按钮时,您需要重新加载表视图([tableView reloadData])。将标签隐藏在

  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

方法