行インデックス パスのセルに動的に 2 つのボタンを含むカスタム テーブル ビューがあります。
クリックするとサイズが大きくなり、ボタンが非表示になり、
次に、行の高さのサイズを変更するためのボタンが1つ表示されるはずです-よろしくお願いします。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return JcOutCellSize;
}
- (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];
}
// ----------------------- cellbackground image-----------------------------
cell.backgroundView =[[UIImageView alloc]initWithFrame:CGRectMake(160, 151, 320, 108)];
cell.backgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"inCellFullBg.png"]];
//*********** Change Cell BackGround Colour*****
// cell.contentView.backgroundColor = [UIColor darkGrayColor];
//----------------------------Cell buttons-------------------------------------------
if (JcOutCellSize==152)
{
UIButton *AddComment = [UIButton buttonWithType:UIButtonTypeCustom]; // custom means transparent it takes shape same with backgroup image
[AddComment addTarget:self
action:@selector(TestBtns:)
forControlEvents:UIControlEventTouchDown];
// [AddComment setTitle:@"1" forState:UIControlStateNormal];
AddComment.frame = CGRectMake(9.0, 128.0, 96.0, 26.0);
[cell.contentView addSubview:AddComment];
UIImage *buttonAddComment = [UIImage imageNamed:@"addcomment.png"];
[AddComment setBackgroundImage:buttonAddComment forState:UIControlStateNormal];
[cell.contentView addSubview:AddComment];
}
if (JcOutCellSize==152)
{
NSLog(@" up arrow %f",JcOutCellSize);
UIButton *UpArrow = [UIButton buttonWithType:UIButtonTypeCustom];
[UpArrow addTarget:self
action:@selector(ResizeCell:)
forControlEvents:UIControlEventTouchDown];
//[DownArrow setTitle:@"Arrow" forState:UIControlStateNormal];
UpArrow.frame = CGRectMake(143.0, 136.0, 26.0, 16.0);
[cell.contentView addSubview:UpArrow];
UIImage *buttonUp = [UIImage imageNamed:@"upArrow.png"];
[UpArrow setBackgroundImage:buttonUp forState:UIControlStateNormal];
[cell.contentView addSubview:UpArrow];
NSLog(@" cell size = %f",JcOutCellSize);
}
//----------------------------------------------------------------------------------
if (JcOutCellSize==132)
{
NSLog(@" down arrow %f",JcOutCellSize);
UIButton *DownArrow = [UIButton buttonWithType:UIButtonTypeCustom];
[DownArrow addTarget:self
action:@selector(IncreseCellHight:)
forControlEvents:UIControlEventTouchDown];
//[DownArrow setTitle:@"Arrow" forState:UIControlStateNormal];
DownArrow.frame = CGRectMake(143.0, 116.0, 26.0, 16.0);
[cell.contentView addSubview:DownArrow];
UIImage *buttondown = [UIImage imageNamed:@"upDownArrow.png"];
[DownArrow setBackgroundImage:buttondown forState:UIControlStateNormal];
[cell.contentView addSubview:DownArrow];
NSLog(@" cell size = %f",JcOutCellSize);
}
return cell;
}
ビューで didload 私はこれをやった JcOutCellSize=152;