2010-07-08 4 views
0

J'utilise la cellule de vue de tableau personnalisé pour montrer à la table vuedéplaçant problème en mode tableau personnalisé cellule

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier 
{ 
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) 
{ 
    m_mail_status = [[UIImageView alloc] initWithFrame:CGRectMake(295, 10, 18, 18)]; 
    [self addSubview:m_mail_status]; 

    m_subject = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 270, 37)]; 
    UIFont* font = m_subject.font; 

    m_subject.font = [UIFont boldSystemFontOfSize:font.pointSize]; 

    //m_subject.font = [UIFont systemFontOfSize:17]; 
    [self addSubview:m_subject]; 

    m_from = [[UILabel alloc] initWithFrame:CGRectMake(10, 37, 200, 15)]; 
    m_from.font = [UIFont systemFontOfSize:12]; 
    [self addSubview:m_from]; 

    m_date = [[UILabel alloc] initWithFrame:CGRectMake(180, 37, 140, 15)]; 
    m_date.textAlignment= UITextAlignmentRight; 
    m_date.font = [UIFont systemFontOfSize:12]; 
    [self addSubview:m_date]; 




} 
return self; 
} 

et mon code dans le contrôleur de vue,

static NSString *MyIdentifier = @"ProductsCell"; 
InboxViewCell *cell = (InboxViewCell*)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

//static NSString *CellIdentifier = @"Cell"; 

// UITableViewCell *cell = nil;// [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"xx"] autorelease]; 


if(cell == nil) 
    cell = [[[InboxViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 


    cell.m_subject.text = [[inbox objectAtIndex:indexPath.row] objectForKey:@"subject"]; 
    cell.m_from.text = [[inbox objectAtIndex:indexPath.row] objectForKey:@"from"]; 
    cell.m_date.text = [[inbox objectAtIndex:indexPath.row] objectForKey:@"date"]; 

    if([[[inbox objectAtIndex:indexPath.row] objectForKey:@"**reservation_status**"] isEqualToString:@"1"])  
    { 
    cell.m_mail_status.image = [UIImage imageNamed:@"reservation_symbol.png"]; 
    } 

Il charge de manière appropriée lorsque il charge d'abord Le problème quand je fais défiler vers le bas et déplace vers le haut toute l'image est montrée il ignore le résultat de l'instruction if

Merci dans advan CE

Cordialement, sathish

Répondre

0

La raison est que les cellules sont réutilisées, vous souhaiterez régler cette image dans l'autre de votre si.