- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row=[indexPath row];
static NSString *CellIdentifier = @"prepaidvViewCustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"prepaidvViewCustomCell" owner:self options:nil];
if([nib count]>0)
{
cell = self.customCell;
}
else
{
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
}
}
lblprePaidName = (UILabel *)[cell.contentView viewWithTag:klblNameTag];
NSString *cellValue = [self.aryPrepaidName objectAtIndex:indexPath.row];
lblprePaidName.text = cellValue;
[cell.contentView addSubview:lblprePaidName];
NSString *temp = [aryimage开发者_如何学JAVAName objectAtIndex:indexPath.row];
imageForSim.image= [UIImage imageNamed:temp];
[cell.contentView addSubview:imageForSim];
[cell.contentView addSubview:lblCallRates];
temp= [aryCallRates objectAtIndex:indexPath.row];
lblCallRates.text=temp;
return cell;
}
An important think you need to understand is, when scrolling every time a new cell create. so you need to create a custom cell creation method. using that it only one time create and it maintain all data correctly
inside that method you write the whatever object you need initialize and use. inside the cellrowindexpath method just use the object. (viewwithtag)
精彩评论