Guest User

Untitled

a guest
Dec 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2.  
  3. static NSString *MyIdentifier = @"MyIdentifier";
  4.  
  5. #if 0
  6. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  7. #endif
  8.  
  9. cell = (MainCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  10. if (cell == nil) {
  11. #if 0
  12.  
  13. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
  14.  
  15. #endif
  16.  
  17. [[NSBundle mainBundle] loadNibNamed:@"MainCell" owner:self options:nil];
  18. }
  19.  
  20. // Set up the cell
  21. int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
  22. [cell.topLabel setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
  23. [cell.bottomLabel setText:[[stories objectAtIndex:storyIndex] objectForKey:@"summary"]];
  24.  
  25. NSMutableString *imgstr = [[stories objectAtIndex:storyIndex] objectForKey:@"image"];
  26. // clean up the link
  27. [imgstr replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, [imgstr length])];
  28. [imgstr replaceOccurrencesOfString:@"\n" withString:@"" options:0 range:NSMakeRange(0, [imgstr length])];
  29. [imgstr replaceOccurrencesOfString:@"\t" withString:@"" options:0 range:NSMakeRange(0, [imgstr length])];
  30.  
  31. NSURL *imgurl = [NSURL URLWithString:imgstr];
  32. NSError *err;
  33. NSData *imgdata = [NSData dataWithContentsOfURL:imgurl options:NSMappedRead error:&err];
  34.  
  35. cell.logoImage.image = [UIImage imageWithData:imgdata];
  36. [cell.logoImage sizeThatFits:CGSizeMake(80,80)];
  37.  
  38. cell.topLabel.font=[UIFont fontWithName:@"Georgia" size:14];
  39.  
  40. cell.logoImage.layer.masksToBounds = YES;
  41. cell.logoImage.layer.cornerRadius = 5; //4.5
  42.  
  43. [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
  44.  
  45. return cell;
  46. }
Add Comment
Please, Sign In to add comment