Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 2.18 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Trying to add in app email of a text field
  2. - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
  3.     {
  4.         switch (result)
  5.         {
  6.             case MFMailComposeResultCancelled:
  7.                 break;
  8.             case MFMailComposeResultSaved:
  9.                 break;
  10.             case MFMailComposeResultSent:
  11.                 break;
  12.             case MFMailComposeResultFailed:
  13.                 break;
  14.  
  15.             default:
  16.             {
  17.                 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-("
  18.                                                                delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
  19.                 [alert show];
  20.  
  21.             }
  22.  
  23.                 break;
  24.         }
  25.         [self dismissModalViewControllerAnimated:YES];
  26.     }
  27.  
  28. -(void) showEmailModalView {
  29.  
  30.     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
  31.     picker.mailComposeDelegate = self;
  32.  
  33.     backUpTape = tapeDisplay.text;
  34.     [picker setMessageBody:backUpTape isHTML:NO];
  35.  
  36.     picker.navigationBar.barStyle = UIBarStyleBlack;
  37.  
  38.     [self presentModalViewController:picker animated:YES];
  39. }
  40.  
  41. - (void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  42. {
  43.     if (buttonIndex == 1) {
  44.         UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  45.         [pasteboard setValue:tapeDisplay.text forPasteboardType:@"public.utf8-plain-text"];
  46.     } else if (buttonIndex == 2)
  47.         [self showEmailModalView];
  48.  
  49. }
  50.  
  51. - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  52. {
  53.     UITouch *touch = [touches anyObject];
  54.     CGPoint location = [touch locationInView: self.view];
  55.  
  56.     if (CGRectContainsPoint(tapeDisplay.frame, location)) {
  57.         UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Copy"
  58.                                                         message: @""
  59.                                                        delegate: self cancelButtonTitle: @"Cancel"
  60.                                               otherButtonTitles: @"Copy", @"email", nil];
  61.         [alert show];
  62.     }
  63.  
  64. }