Guest User

Untitled

a guest
Jul 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. static NSString *CellIdentifier = @"Cell";
  2.  
  3. UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
  4. if (cell == nil) {
  5. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  6. //code STATS here : initializing here for cells background view & selection back ground view
  7. cell.backgroundView =
  8. [[[UIImageView alloc] init] autorelease];
  9. cell.selectedBackgroundView =
  10. [[[UIImageView alloc] init] autorelease];
  11.  
  12. //code ENDS HERE of initializing
  13. //custom label
  14.  
  15. UIImage *indicatorImage = [UIImage imageNamed:@"indicator.png"];
  16. cell.accessoryView =
  17. [[[UIImageView alloc]
  18. initWithImage:indicatorImage]
  19. autorelease];
  20.  
  21. const CGFloat LABEL_HEIGHT = 20;
  22. UIImage *image = [UIImage imageNamed:@"filter.png"];//this image is on top //left of section zero rows
  23.  
  24. //
  25. // Create the label for the top row
  26. //
  27.  
  28. topLabel =
  29. [[[UILabel alloc]
  30. initWithFrame:
  31. CGRectMake(
  32. image.size.width + 2.0 * cell.indentationWidth,
  33. 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT),
  34. aTableView.bounds.size.width -
  35. image.size.width - 4.0 * cell.indentationWidth
  36. - indicatorImage.size.width,
  37. LABEL_HEIGHT)]
  38. autorelease];
  39. [cell.contentView addSubview:topLabel];
  40.  
  41. //
  42. // Configure the properties for the text that are the **SAME** on every row
  43. //
  44. topLabel.tag = TOP_LABEL_TAG;
  45. topLabel.backgroundColor = [UIColor clearColor];
  46. topLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
  47. topLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
  48. topLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
  49. //testing:
  50. topLabel.text=@"test1";
  51. //
  52. // Create the label for the top row of text
  53. //
  54. bottomLabel =
  55. [[[UILabel alloc]
  56. initWithFrame:
  57. CGRectMake(
  58. image.size.width + 2.0 * cell.indentationWidth,
  59. 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT) + LABEL_HEIGHT,
  60. aTableView.bounds.size.width -
  61. image.size.width - 4.0 * cell.indentationWidth
  62. - indicatorImage.size.width,
  63. LABEL_HEIGHT)]
  64. autorelease];
  65. [cell.contentView addSubview:bottomLabel];
  66.  
  67. //
  68. // Configure the properties for the text that are the same on every row
  69. //
  70. bottomLabel.tag = BOTTOM_LABEL_TAG;
  71. bottomLabel.backgroundColor = [UIColor clearColor];
  72. bottomLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
  73. bottomLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
  74. bottomLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize] - 2];
  75. bottomLabel.text=@"test2";
  76. }
  77.  
  78.  
  79. //testing for section 2
  80. //this image is on top left of section one rows
  81. UIImage *image1 = [UIImage imageNamed:@"akshardham.jpg"];
  82. topLabel1 =
  83. [[[UILabel alloc]
  84. initWithFrame:
  85. CGRectMake(
  86. image1.size.width + 2.0 * cell.indentationWidth,
  87. 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT),
  88. aTableView.bounds.size.width -
  89. image1.size.width - 4.0 * cell.indentationWidth
  90. - indicatorImage.size.width,
  91. LABEL_HEIGHT)]
  92. autorelease];
  93. [cell.contentView addSubview:topLabel1];
  94.  
  95. topLabel1.tag = TOP_LABEL_TAG1;
  96. topLabel1.backgroundColor = [UIColor clearColor];
  97. topLabel1.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
  98. topLabel1.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
  99. topLabel1.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
  100. //testing:
  101. topLabel1.text=@"test2section";
  102. }
  103.  
  104.  
  105. }
  106.  
  107. else
  108. {
  109. topLabel = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG];
  110. bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG];
  111. topLabel1 = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG1];
  112. }
  113.  
  114. if (cell == nil) {
  115.  
  116. }
  117.  
  118. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  119. static NSString * MYTableViewCellIdentifier = @"MYTableViewCellIdentifier";
  120.  
  121. MyTableViewCell * cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:MYTableViewCellIdentifier];
  122. if (cell == nil) {
  123. // Create the cell
  124. // Global layout for the cell
  125. }
  126. // Customization code
  127. return cell;
  128. }
Add Comment
Please, Sign In to add comment