2013-11-27 1 views
-1
- (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 = [email protected]"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; 

}Я использую пользовательский класс для создания ячейки tableview. Что происходит при прокрутке значений табличного представления?

ответ

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 = [email protected]"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

спасибо за вашу помощь .. но не работает .. – Akshay

Смежные вопросы