Skip to content

Instantly share code, notes, and snippets.

@ahmetardal
Created June 9, 2011 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmetardal/1017722 to your computer and use it in GitHub Desktop.
Save ahmetardal/1017722 to your computer and use it in GitHub Desktop.
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellId = @"CopyableCell";
CopyableCell *cell = (CopyableCell *) [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil) {
cell = [[[CopyableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
}
[cell setIndexPath:indexPath];
[cell setDelegate:self];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.text = [self.tableData objectAtIndex:indexPath.row];
return cell;
}
#pragma mark -
#pragma mark CopyableCellDelegate Methods
- (void) copyableCell:(CopyableCell *)cell selectCellAtIndexPath:(NSIndexPath *)indexPath
{
[self.demoTableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
- (void) copyableCell:(CopyableCell *)cell deselectCellAtIndexPath:(NSIndexPath *)indexPath
{
[self.demoTableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (NSString *) copyableCell:(CopyableCell *)cell dataForCellAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row < self.tableData.count) {
return [self.tableData objectAtIndex:indexPath.row];
}
return @"";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment