- Trying to add in app email of a text field
- - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
- {
- switch (result)
- {
- case MFMailComposeResultCancelled:
- break;
- case MFMailComposeResultSaved:
- break;
- case MFMailComposeResultSent:
- break;
- case MFMailComposeResultFailed:
- break;
- default:
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-("
- delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
- [alert show];
- }
- break;
- }
- [self dismissModalViewControllerAnimated:YES];
- }
- -(void) showEmailModalView {
- MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
- picker.mailComposeDelegate = self;
- backUpTape = tapeDisplay.text;
- [picker setMessageBody:backUpTape isHTML:NO];
- picker.navigationBar.barStyle = UIBarStyleBlack;
- [self presentModalViewController:picker animated:YES];
- }
- - (void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex == 1) {
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
- [pasteboard setValue:tapeDisplay.text forPasteboardType:@"public.utf8-plain-text"];
- } else if (buttonIndex == 2)
- [self showEmailModalView];
- }
- - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- {
- UITouch *touch = [touches anyObject];
- CGPoint location = [touch locationInView: self.view];
- if (CGRectContainsPoint(tapeDisplay.frame, location)) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Copy"
- message: @""
- delegate: self cancelButtonTitle: @"Cancel"
- otherButtonTitles: @"Copy", @"email", nil];
- [alert show];
- }
- }