Guest User

Untitled

a guest
May 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  2. return 1;
  3.  
  4. #define kTagMyLabel 1
  5.  
  6. - (UITableViewCell *)tableView:(UITableView *)tableView
  7. cellForRowAtIndexPath:(NSIndexPath *)indexPath
  8. {
  9. static NSString *cellID = @"Cell1";
  10. UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
  11. UILabel * l;
  12. if (cell == nil) {
  13. // create the cell
  14. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
  15.  
  16. // perform setup/functions that are common to all cells
  17. l = [[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)] autorelease];
  18. l.font=[UIFont boldSystemFontOfSize:15];
  19. l.textColor=[UIColor whiteColor];
  20. l.backgroundColor=[UIColor blackColor];
  21. l.tag = kTagMyLabel ;
  22. [cell.contentView addSubview:l];
  23. }
  24. else
  25. {
  26. // find the label we previously added.
  27. l = (UILabel*)[cell viewWithTag:kTagMyLabel];
  28. }
  29.  
  30. // now set up the cell specific to this indexPath
  31. l.text=@"Just some random text here";
  32. return cell;
  33. }
  34.  
  35. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  36. return 40;
  37.  
  38. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  39. return 100;
  40.  
  41. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  42. static NSString *cellID = @"Cell";
  43. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  44. UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
  45. if (cell == nil) {
  46. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
  47. }
  48. UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
  49. l.font=[UIFont boldSystemFontOfSize:15];
  50. l.textColor=[UIColor whiteColor];
  51. l.backgroundColor=[UIColor blackColor];
  52. l.text=@"Just some randoom text here";
  53. [cell.contentView addSubview:l];
  54. [l release];
  55. return cell;
  56. }
  57.  
  58. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  59. static NSString *cellID = @"Cell";
  60. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  61. UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
  62. if (cell == nil) {
  63. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellID] autorelease];
  64. UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,10,300,16)];
  65. l.font=[UIFont boldSystemFontOfSize:15];
  66. l.textColor=[UIColor whiteColor];
  67. l.backgroundColor=[UIColor blackColor];
  68. l.text=@"Just some randoom text here";
  69. [cell.contentView addSubview:l];
  70. [l release];
  71. }
  72. return cell;
  73. }
Add Comment
Please, Sign In to add comment