2010-07-04 11 views
1

Dans ma vue de table j'avais plus de 200 rangées et je réussis alors en gardant loadmoreresults dans la dernière cellule pour montrer seulement 40 rangées par page. Quand l'utilisateur clique sur le chargement plus de résultats 40 plus de cellules est affichées. de loadmoreresults cellule comme différent de l'autre. Le problème est quand il n'y a plus de résultats la taille pour l'autre cellule est effectuée avec la taille de la cellule loadmoreresults Je ne veux pas affecter la hauteur de la dernière rangée aux autres rangées.Comment changer la hauteur de ligne pour seulement la dernière cellule d'une tableview?

Le code I écrit:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
ZohoAppDelegate* appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate]; 

int maxResults = [appDelegate.invoiceMaxValues intValue]; 
int noOfResults = [invoiceArray count] ; 
if (noOfResults != 0) 
{ 
    if (maxResults > noOfResults) 
    { 
     noOfResults++; 
     rowCount = noOfResults; 
    } 
} 
return noOfResults; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if(indexPath.row == (rowCount -1)) 
{ 
    return 50; 
} 
return 80; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 
if (cell == nil) 
{ 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease]; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    UIView* elementView = [[UIView alloc] initWithFrame:CGRectMake(5,5,312,480)]; 
    elementView.tag = 0; 
    [cell.contentView addSubview:elementView]; 
    [elementView release]; 
} 
UIView* elementView = [cell.contentView viewWithTag:0]; 
for(UIView* subView in elementView.subviews) 
{ 
    [subView removeFromSuperview]; 
} 

UIImageView* imaeView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 78)]; 
if(indexPath.row == (rowCount-1)) 
{ 
    elementView.backgroundColor = [UIColor colorWithRed:0.92578125 green:0.92578125 blue:0.92578125 alpha:1]; 
} 
else 
{ 
    imaeView.image=[UIImage imageNamed:@"estimatecellbg.png" ]; 
} 
[elementView addSubview:imaeView]; 
[imaeView release]; 
    return cell; 
    } 

l'aide de personne sera très appréciée.

Merci, Monish.

Répondre

2

Quelque chose le long des lignes de

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(indexPath.row == (rowCount -1) && moreResults) 
    { 
     return 50; 
    } 
    return 80; 
} 
Questions connexes