Guest User

Untitled

a guest
Jul 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2. static NSString * CellIdentifier = @"Cell";UIImageView * myImageView;
  3.  
  4. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  5. UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,66,49)] autorelease];
  6. if (cell == nil) {
  7. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
  8. }
  9.  
  10. [cell.textLabel setTextColor:[UIColor whiteColor]];
  11. [cell.textLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14]];
  12.  
  13. if (newsArray) {
  14. if(indexPath.row % 2 == 0) {
  15. [cell.contentView setBackgroundColor:[UIColor colorWithRed:0.145 green:0.145 blue:0.145 alpha:0.0]];
  16. } else {
  17. [cell.contentView setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.0]];
  18. }
  19. UIImage *image = [UIImage imageNamed:@"test.jpg"];
  20. UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
  21. CGRect frame;
  22. frame.origin = CGPointZero;
  23. frame.size = [image size];
  24. [imageView setFrame:frame];
  25. [cell.contentView addSubview:myImageView];
  26. [imageView release];
  27. [cell.textLabel setTextAlignment:UITextAlignmentLeft];
  28. [cell.textLabel setText:[[newsArray objectAtIndex:indexPath.row] objectForKey:@"title"]];
  29. [cell.detailTextLabel setText:[[newsArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
  30. [cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
  31. } else {
  32. [cell.textLabel setTextAlignment:UITextAlignmentCenter];
  33. [cell.textLabel setText:@"Loading..."];
  34. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  35. }
  36.  
  37. return cell;
  38. }
Add Comment
Please, Sign In to add comment