0

单击按钮时如何在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;
        }
    }
4

1 回答 1

0

当您单击具有更新高度的按钮并隐藏标签时,您需要重新加载表格视图([tableView reloadData])

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

方法。

于 2013-01-25T06:28:41.523 回答