Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 1.80 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. UITableView redrawing without image and cell replaced
  2. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  3. {      
  4.     static NSString *CellIdentifierText = @"TextCell";
  5.     static NSString *CellIdentifierImage = @"ImageCell";
  6.  
  7.     if (indexPath.section == 0)
  8.     {
  9.         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierImage];
  10.  
  11.         if (cell == nil)
  12.         {
  13.             cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierImage] autorelease];
  14.             UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,180)];                
  15.             imageView.tag = 1;
  16.             imageView.image = [UIImage imageNamed:@"prem.jpg"];
  17.             [cell addSubview:imageView];
  18.             [imageView release];
  19.         }
  20.         return cell;
  21.     }
  22.     else    {
  23.         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierText];
  24.         if (cell == nil)
  25.         {
  26.  
  27.             cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifierImage] autorelease];
  28.         }      
  29.         if(indexPath.section == 1)          
  30.             cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];      
  31.         else if(indexPath.section ==2)
  32.             cell.textLabel.text = [arryAddressInfo objectAtIndex:indexPath.row];
  33.         else if(indexPath.section == 3)        
  34.             cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];      
  35.         else if(indexPath.section == 4)
  36.             cell.textLabel.text = @"REPLACE ME WITH ICONS";
  37.  
  38.         return cell;  
  39.     }
  40. }
  41.        
  42. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:**CellIdentifierImage**] autorelease];