Skip to content

Instantly share code, notes, and snippets.

@ahmetardal
Created July 3, 2011 16:17
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/1062353 to your computer and use it in GitHub Desktop.
Save ahmetardal/1062353 to your computer and use it in GitHub Desktop.
EmailableCell Usage
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellId = @"EmailableCell";
EmailableCell *cell = (EmailableCell *) [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil) {
cell = [[[EmailableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
}
[cell setIndexPath:indexPath];
[cell setDelegate:self];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.text = [self.emailAddresses objectAtIndex:indexPath.row];
return cell;
}
#pragma mark -
#pragma mark EmailableCellDelegate Methods
- (void) emailableCell:(EmailableCell *)cell selectCellAtIndexPath:(NSIndexPath *)indexPath
{
[self.demoTableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
- (void) emailableCell:(EmailableCell *)cell deselectCellAtIndexPath:(NSIndexPath *)indexPath
{
[self.demoTableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (NSString *) emailableCell:(EmailableCell *)cell emailAddressForCellAtIndexPath:(NSIndexPath *)indexPath
{
return [self.emailAddresses objectAtIndex:indexPath.row];
}
- (void) emailableCell:(EmailableCell *)cell didPressSendEmailOnCellAtIndexPath:(NSIndexPath *)indexPath
{
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
if (controller == nil) {
return;
}
controller.mailComposeDelegate = self;
NSString *emailAddress = [self.emailAddresses objectAtIndex:indexPath.row];
[controller setToRecipients:[NSArray arrayWithObject:emailAddress]];
[self presentModalViewController:controller animated:YES];
[controller release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment