- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *leftTableIdentifier = @"Cell";
customTableCell *cell = (customTableCell *)[tableView dequeueReusableCellWithIdentifier:leftTableIdentifier];
if (!cell)
{
//cell = [[customTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:leftTableIdentifier];
NSArray *ar = [[NSBundle mainBundle]loadNibNamed:@"customTable" owner:nil options:nil];
cell= [ar objectAtIndex:0];
}
BOOL isSelected = [selectedArray containsObject:indexPath];
cell.lblInfo.numberOfLines = isSelected?0:2;
NSString *text = [items objectAtIndex:indexPath.row];
cell.lblInfo.text = text;
NSString *buttonTitle = isSelected?@"See Less":@"See More";
[cell.btnTitle setTitle:buttonTitle forState:UIControlStateNormal];
[cell.btnTitle setBackgroundColor:[UIColor redColor]];
[cell.btnTitle addTarget:self action:@selector(clickMe:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnTitle setTag:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
答案 0 :(得分:0)
尝试
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *leftTableIdentifier = @"Cell";
customTableCell *cell = (customTableCell *)[tableView dequeueReusableCellWithIdentifier:leftTableIdentifier];
if (!cell)
{
//cell = [[customTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:leftTableIdentifier];
NSArray *ar = [[NSBundle mainBundle]loadNibNamed:@"customTable" owner:nil options:nil];
cell= [ar objectAtIndex:0];
BOOL isSelected = [selectedArray containsObject:indexPath];
cell.lblInfo.numberOfLines = isSelected?0:2;
NSString *text = [items objectAtIndex:indexPath.row];
cell.lblInfo.text = text;
NSString *buttonTitle = isSelected?@"See Less":@"See More";
[cell.btnTitle setTitle:buttonTitle forState:UIControlStateNormal];
[cell.btnTitle setBackgroundColor:[UIColor redColor]];
[cell.btnTitle addTarget:self action:@selector(clickMe:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnTitle setTag:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}