Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. NSInteger row = [indexPath row];
  4. NSInteger section = [indexPath section];
  5.  
  6. ModuleTableCellView *cell = [tableView dequeueReusableCellWithIdentifier:@"course-activity"];
  7.  
  8. if (cell == nil)
  9. {
  10. cell = [[[ModuleTableCellView alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"course-activity"] autorelease];
  11.  
  12. UIImage *image = [UIImage imageNamed:@"download.png"];
  13. // responding to events
  14. UIControl *downloadIcon = [[UIControl alloc] initWithFrame:(CGRect) { CGPointZero, image.size }];
  15. downloadIcon.layer.contents = (id)image.CGImage;
  16. [downloadIcon addTarget:self action:@selector(accessoryButtonTapped:withEvent:) forControlEvents:UIControlEventTouchUpInside ];
  17. cell.accessoryView = downloadIcon;
  18. [downloadIcon release];
  19.  
  20. cell.textLabel.text = [NSString stringWithFormat:@"This is label %d/%d", section, row];
  21.  
  22. cell.detailTextLabel.text = @"This is the content of the label";
  23. }
  24. return cell;
  25. }
  26.  
  27. - (void)accessoryButtonTapped:(UIControl *)button withEvent:(UIEvent *)event
  28. {
  29. NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:[[[event touchesForView:button] anyObject] locationInView:tableView]];
  30.  
  31. if ( indexPath == nil )
  32. {
  33. return;
  34. }
  35.  
  36.  
  37. [tableView.delegate tableView:tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
  38. }
  39.  
  40.  
  41. - (void)tableView:(UITableView *)_tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
  42. {
  43. // perform the action here
  44. }
Add Comment
Please, Sign In to add comment