8
I want to expand the cell size after clicking a seeMoreBtn on cell.
The label and cells have varying length, but their is a constraint in size of label.
When a status is too big, I added a seeMoreBtn, after clicking on see more the remaining text will be shown below, then how to increase the label and cell size.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSString *text = [items objectAtIndex:[indexPath row]];
CGSize constraint = CGSizeMake(300.0f, 150.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:constraint lineBreakMode:NSLineBreakByCharWrapping];
CGFloat height1 = MAX(size.height, 44.0f);
return height1 + (40.0f);
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell-%d",indexPath.row];
cell=[tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
int lbltag = 1000;
label=[[UILabel alloc]initWithFrame:CGRectZero];
[label setLineBreakMode:NSLineBreakByWordWrapping];
[label setMinimumScaleFactor:14.0f];
[label setNumberOfLines:0];
[label setFont:[UIFont systemFontOfSize:14.0f]];
NSString *text = [items objectAtIndex:[indexPath row]];
[label setText:text];
label.tag = lbltag;
[cell addSubview:label];
CGSize constraint1=CGSizeMake(300.0f, 150.0f);
CGSize size1=[text sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:constraint1 lineBreakMode:NSLineBreakByWordWrapping];
[label setFrame:CGRectMake(10.0f, 10.0f, 300.0f, MAX(size1.height, 44.0f))];
int countText=text.le