Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSInteger row = [indexPath row];
- NSInteger section = [indexPath section];
- ModuleTableCellView *cell = [tableView dequeueReusableCellWithIdentifier:@"course-activity"];
- if (cell == nil)
- {
- cell = [[[ModuleTableCellView alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"course-activity"] autorelease];
- UIImage *image = [UIImage imageNamed:@"download.png"];
- // responding to events
- UIControl *downloadIcon = [[UIControl alloc] initWithFrame:(CGRect) { CGPointZero, image.size }];
- downloadIcon.layer.contents = (id)image.CGImage;
- [downloadIcon addTarget:self action:@selector(accessoryButtonTapped:withEvent:) forControlEvents:UIControlEventTouchUpInside ];
- cell.accessoryView = downloadIcon;
- [downloadIcon release];
- cell.textLabel.text = [NSString stringWithFormat:@"This is label %d/%d", section, row];
- cell.detailTextLabel.text = @"This is the content of the label";
- }
- return cell;
- }
- - (void)accessoryButtonTapped:(UIControl *)button withEvent:(UIEvent *)event
- {
- NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:[[[event touchesForView:button] anyObject] locationInView:tableView]];
- if ( indexPath == nil )
- {
- return;
- }
- [tableView.delegate tableView:tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
- }
- - (void)tableView:(UITableView *)_tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
- {
- // perform the action here
- }
Add Comment
Please, Sign In to add comment