Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3.  
  4. UILabel *mainLabel, *secondLabel;
  5. UIImageView *photo;
  6. UITableViewCell * cell = [myTableView dequeueReusableCellWithIdentifier:@"rssItemCell"];
  7.  
  8. if(cell == nil)
  9. {
  10.  
  11. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"rssItemCell"] autorelease];
  12. cell.accessoryType = UITableViewCellAccessoryNone;
  13.  
  14. mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 235.0, 15.0)] autorelease];
  15. mainLabel.tag = MAINLABEL_TAG;
  16. mainLabel.font = [UIFont systemFontOfSize:14.0];
  17. mainLabel.textAlignment = UITextAlignmentRight;
  18. mainLabel.textColor = [UIColor blackColor];
  19. mainLabel.backgroundColor = [UIColor clearColor];
  20. mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  21. [cell.contentView addSubview:mainLabel];
  22.  
  23. secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 20.0, 235.0, 25.0)] autorelease];
  24. secondLabel.tag = MAINLABEL_TAG;
  25. secondLabel.font = [UIFont systemFontOfSize:10.0];
  26. secondLabel.textAlignment = UITextAlignmentRight;
  27. secondLabel.textColor = [UIColor blackColor];
  28. secondLabel.backgroundColor = [UIColor clearColor];
  29. secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  30. [cell.contentView addSubview:secondLabel];
  31.  
  32. photo = [[[UIImageView alloc] initWithFrame:CGRectMake(238.0, 2.0, 80.0, 40.0)] autorelease];
  33. photo.tag = PHOTO_TAG;
  34. photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  35. [cell.contentView addSubview:photo];
  36. NSLog(@"calling list if nil");
  37.  
  38. }
  39.  
  40. else
  41. {
  42. mainLabel = (UILabel *) [cell.contentView viewWithTag:MAINLABEL_TAG];
  43. secondLabel = (UILabel *) [cell.contentView viewWithTag:SECONDLABEL_TAG];
  44. photo = (UIImageView *) [cell.contentView viewWithTag:PHOTO_TAG];
  45.  
  46. }
  47. NSLog(@"calling list %d",indexPath.row);
  48. static NSDictionary* hasLoaded;
  49.  
  50.  
  51.  
  52. RssData *data = [[[self rssParser] rssItems] objectAtIndex:indexPath.row];
  53.  
  54. mainLabel.text = [self ConvertNumToFarsi:[data title]];
  55. secondLabel.text = [self ConvertNumToFarsi:[data description]];
  56. // photo.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[data mediaUrl]]]];
  57. [photo setImage:nil];
  58. NSOperationQueue *queue = [NSOperationQueue new];
  59. NSArray* argArray;
  60. argArray=[NSArray arrayWithObjects:data,photo,nil];
  61. NSInvocationOperation *operation = [[NSInvocationOperation alloc]
  62. initWithTarget:self
  63. selector:@selector(loadImage:)
  64. object:(id)argArray];
  65.  
  66.  
  67.  
  68. [queue addOperation:operation];
  69. [operation release];
  70. //To customize the selected tableview cell
  71. //cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"effect"]]autorelease];
  72.  
  73.  
  74.  
  75. [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
  76.  
  77. return cell;
  78.  
  79. }
Add Comment
Please, Sign In to add comment