开发者

How to hide the Mycustom button in tableView cell

I want to hide custom button present in tableview cell for a specific condition.

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 
 {
     if(isDisplayMapbutton==YES)
   {                           
         UIView* buttonView1 =开发者_C百科 [[UIView alloc] init];
         mapBtn= [[MyCustomButton alloc] initWithIndexPath:indexPath];
         CGRect imageFrame1 = CGRectMake(0,2.0,30,30);  
         [buttonView1 setFrame: CGRectMake(230,3.0,30,30 ) ];
         [mapBtn setFrame:imageFrame1];
         [mapBtn setBackgroundImage: [UIImage imageNamed:@"Map.png"] forState:UIControlStateNormal];
         [mapBtn addTarget:self  action:@selector(DisplayMap:)forControlEvents:UIControlEventTouchUpInside];

         [buttonView1 addSubview:mapBtn];
         [cell.contentView addSubview:buttonView1];
         [buttonView1 release];

        [mapBtn release];
    }
    else        
    {

    }
  return cell;
}

-(void)toggleMove
  {
     if(isMove==YES)
     {
        isDisplayMapbutton  =NO;

        isMove=NO;
        //mapBtn.hidden=YES;
        [self getToolbar];
    }
    else
    {
        isDisplayMapbutton =YES;
     isMove=YES;
     //mapBtn.hidden=NO;

         [self getToolbar];
    }
    [tableView reloadData];
    [self.tableView setEditing:!self.tableView.editing animated:YES];
}

If I use the above method ,[self.tableView setEditing:!self.tableView.editing animated:YES]; the cell will be compressed. then map btn is moving to the end of cell. HOW to hide this Map

button when we call the above method


Right after you release mapBtn, do something like this

mapBtn = (MyCustomButton *) [cell.contentView viewWithTag: 1];

and also place this after the mapBtn method calls

mapBtn.tag = 1;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜