2011-06-28 9 views
0
- (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 = [aryimageName 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; 

} 
+0

良いフォーマットはあなたの友人です –

答えて

0

重要なことは、新しいセルが作成されるたびにスクロールするときに理解する必要があると考えます。カスタムセル作成メソッドを作成する必要があります。それを一度だけ作成し、すべてのデータを正しく維持することをお勧めします。

このメソッドの内部には、初期化して使用する必要があるオブジェクトを記述します。 cellrowindexpathメソッドの中でオブジェクトを使用するだけです。 (viewwithtag)

+0

ありがとうございます。 Maheswaran –

関連する問題