daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3.  
  4.    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
  5.  
  6.     if (cell==nil) {
  7.         cell=[[UITableViewCell alloc]init];
  8.     }
  9.  
  10.      if([indexPath row] == 0){
  11.         cell.textLabel.text=@"mano";
  12.         cell.backgroundColor = [UIColor redColor];
  13.  
  14.     }
  15.     if([indexPath row] == 1){
  16.         cell.textLabel.text=@"happy";
  17.         cell.backgroundColor=[UIColor whiteColor];
  18.     }
  19.     if([indexPath row] == 2){
  20.         cell.textLabel.text=@"welcome";
  21.         cell.backgroundColor=[UIColor grayColor];
  22.     }
  23.      if([indexPath row] == 3)
  24.      {
  25.          cell.textLabel.text=@"enjoy";
  26.          cell.backgroundColor=[UIColor magentaColor];
  27.      }
  28.         return cell;
  29. }
  30.    
  31. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
  32.    
  33. NSString *file = [[NSBundle mainBundle] pathForResource:[self.photos objectAtIndex:self.currentIndex] ofType:nil];
  34.  
  35. cell.imageView.image = [UIImage imageWithContentsOfFile:file]
  36.    
  37. cell.imageView.image = [UIImage imageNamed:@"imageName.png"];
  38.    
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  40. {
  41.  
  42.   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
  43.  
  44. if (cell==nil) {
  45.     cell=[[UITableViewCell alloc]init];
  46. }
  47.  
  48.  
  49.  
  50. if([indexPath row] == 0){
  51.     cell.textLabel.text=@"mano";
  52.     cell.backgroundColor = [UIColor redColor];
  53.     cell.imageView.image = [UIImage imageNamed:@"arrow0.png"];
  54.  
  55. }
  56. if([indexPath row] == 1){
  57.     cell.textLabel.text=@"happy";
  58.     cell.backgroundColor=[UIColor whiteColor];
  59.     cell.imageView.image = [UIImage imageNamed:@"arrow1.png"];
  60.  
  61. }
  62. if([indexPath row] == 2){
  63.     cell.textLabel.text=@"welcome";
  64.     cell.backgroundColor=[UIColor grayColor];
  65.     cell.imageView.image = [UIImage imageNamed:@"arrow2.png"];
  66.  
  67. }
  68.  if([indexPath row] == 3)
  69.  {
  70.      cell.textLabel.text=@"enjoy";
  71.      cell.backgroundColor=[UIColor magentaColor];
  72. cell.imageView.image = [UIImage imageNamed:@"arrow3.png"];
  73.  }
  74.     return cell;
  75. }
  76.    
  77. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  78.     {
  79.  
  80.        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
  81.  
  82.      if (cell == nil) {
  83.           cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault    reuseIdentifier:@"MyIdentifier"];
  84.  
  85.     }
  86.  
  87.              cell.imageView.image = [UIImage imageNamed:@"image.png"];
  88.              cell.backgroundColor=[UIColor magentaColor];
  89.  
  90.             return cell;
  91.  
  92. }
  93.  
  94. If you have used storyboard then no need to check if cell is nil. It intializes cell automatically when dequeing is not possible. Please check this tutorial.
  95.    
  96. cell.accessoryView = UIImageView(image:UIImage(named:"imageNmae")!)
RAW Paste Data
Top