I am using custom table view cell to show to table view
- (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;
}
and my code in view controller,
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"];
}
It loads in proper manner when it first loads
The issue when i scroll down and move to up
all the image is shown it ignores the if statement result
Thanks in advance
Regards,
sathish
The reason for this is that the cells are reused, you will want to reset that image in the else of your if.