Created
July 3, 2011 16:17
-
-
Save ahmetardal/1062353 to your computer and use it in GitHub Desktop.
EmailableCell Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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