Guest User

Untitled

a guest
Aug 16th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. reload uitableview data in cell out of view
  2. [self.countryList reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone]; // or NO ;)
  3.  
  4. if (cell == nil) {
  5.  
  6. cell =[[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identifier]autorelease];
  7. //[cell setBackgroundColor: [UIColor clearColor]];
  8.  
  9.  
  10.  
  11.  
  12. mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(52.0, 0.0, 200.0, 20.0)] autorelease];
  13. mainLabel.tag = 1;
  14. mainLabel.font = [UIFont systemFontOfSize:14.0];
  15. mainLabel.textAlignment = UITextAlignmentLeft;
  16. mainLabel.textColor = [UIColor blackColor];
  17. mainLabel.opaque = YES;
  18. mainLabel.backgroundColor=[UIColor clearColor];
  19. [cell.contentView addSubview:mainLabel];
  20.  
  21. revenue = [[[UILabel alloc] initWithFrame:CGRectMake(52.0, 20.0, 150.0, 20.0)] autorelease];
  22. revenue.tag = 3;
  23. revenue.font = [UIFont systemFontOfSize:14.0];
  24. revenue.textAlignment = UITextAlignmentLeft;
  25. revenue.textColor = [UIColor blackColor];
  26. revenue.opaque = YES;
  27. revenue.backgroundColor=[UIColor clearColor];
  28. [cell.contentView addSubview:revenue];
  29.  
  30. promos = [[[UILabel alloc] initWithFrame:CGRectMake(252.0, 20.0, 150.0, 20.0)] autorelease];
  31. promos.tag = 4;
  32. promos.font = [UIFont systemFontOfSize:14.0];
  33. promos.textAlignment = UITextAlignmentLeft;
  34. promos.textColor = [UIColor blackColor];
  35. promos.opaque = YES;
  36. promos.backgroundColor=[UIColor clearColor];
  37. [cell.contentView addSubview:promos];
  38.  
  39. updates = [[[UILabel alloc] initWithFrame:CGRectMake(252.0, 0.0, 200.0, 20.0)] autorelease];
  40. updates.tag = 5;
  41. updates.font = [UIFont systemFontOfSize:14.0];
  42. updates.textAlignment = UITextAlignmentLeft;
  43. updates.textColor = [UIColor blackColor];
  44. updates.opaque = YES;
  45. updates.backgroundColor=[UIColor clearColor];
  46. [cell.contentView addSubview:updates];
  47.  
  48. photo = [[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 50.0)] autorelease];
  49. photo.contentMode= UIViewContentModeScaleToFill;
  50. photo.tag = 2;
  51. photo.opaque = YES;
  52. photo.backgroundColor=[UIColor clearColor];
  53. [cell.contentView addSubview:photo];
  54.  
  55. }
  56. else {
  57. cell.clearsContextBeforeDrawing=YES;
  58. mainLabel = (UILabel *)[cell.contentView viewWithTag:1];
  59. photo = (UIImageView *)[cell.contentView viewWithTag:2];
  60. promos=(UILabel *)[cell.contentView viewWithTag:4];
  61. revenue=(UILabel *)[cell.contentView viewWithTag:3];
  62. updates=(UILabel *)[cell.contentView viewWithTag:5];
  63.  
  64.  
  65. if(photo.image){
  66. photo.image=nil;
  67. }
  68. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
  69. NSString *documentsDirectory = [paths objectAtIndex:0];
  70. NSString *imageURL =[NSString stringWithString:[(arrayResults*)[tweets objectAtIndex:indexPath.row] myCountryIcon]];
  71.  
  72. NSArray *myArray = [imageURL componentsSeparatedByString: @"/"];
  73. NSString *fileName = [NSString stringWithString:[myArray lastObject]];
  74. NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/AppIcons"];
  75. NSString* path = [dataPath stringByAppendingPathComponent:fileName];
  76. UIImage* image = [UIImage imageWithContentsOfFile:path];
  77. if (!image) {
  78.  
  79. UIApplication* app = [UIApplication sharedApplication];
  80. app.networkActivityIndicatorVisible = YES;
  81. // Create an array with the URL and name.
  82. NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:fileName,imageURL, nil ];
  83.  
  84.  
  85. [self performSelectorInBackground:@selector(loadImageInBackground:) withObject:arr];
  86. [arr release];
  87.  
  88.  
  89. }
  90. else{
  91. photo.image=image;
  92.  
  93.  
  94. }
  95. NSString*promostext=[[NSString alloc] initWithFormat:@"promos:%@",[[(arrayResults*)[tweets objectAtIndex:indexPath.row] mypromos]stringValue] ];
  96. NSString*revenuetext=[[NSString alloc] initWithFormat:@"revenue:%@",[(arrayResults*)[tweets objectAtIndex:indexPath.row] myrevenue] ];
  97. NSString*updatestext=[[NSString alloc] initWithFormat:@"updates:%@",[[(arrayResults*)[tweets objectAtIndex:indexPath.row] myupdates]stringValue] ];
  98.  
  99. mainLabel.text=[(arrayResults*)[tweets objectAtIndex:indexPath.row] myCountryName];
  100. promos.text=promostext;
  101. revenue.text=revenuetext;
  102. updates.text=updatestext;
  103. [promostext release];
  104. [revenuetext release];
  105. [updatestext release];
  106.  
  107. }
Add Comment
Please, Sign In to add comment