Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this code, this works well without crashing.. contact us method is button target selector..</p> <pre><code> -(void)ContactUs:(UIButton*)button { Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); if (mailClass != nil) { // We must always check whether the current device is configured for sending emails if ([mailClass canSendMail]) { [self displayComposerSheet]; } else { [self launchMailAppOnDevice]; } } else { [self launchMailAppOnDevice]; } } -(void)displayComposerSheet { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; //[picker setSubject:@"Hello from California!"]; // Set up recipients NSArray *toRecipients = [NSArray arrayWithObject:@"info@imp.co.in"]; //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; //NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; [picker setToRecipients:toRecipients]; //[picker setCcRecipients:ccRecipients]; //[picker setBccRecipients:bccRecipients]; // Attach an image to the email /*NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"png"]; NSData *myData = [NSData dataWithContentsOfFile:path]; [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"rainy"];*/ // Fill out the email body text //NSString *emailBody = @"It is raining in sunny California!"; //[picker setMessageBody:emailBody isHTML:NO]; [self presentModalViewController:picker animated:YES]; [picker release]; } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { message.hidden = NO; // Notifies users about errors associated with the interface switch (result) { case MFMailComposeResultCancelled: message.text = @"Canceled"; break; case MFMailComposeResultSaved: message.text = @"Saved"; break; case MFMailComposeResultSent: message.text = @"Sent"; break; case MFMailComposeResultFailed: message.text = @"Failed"; break; default: message.text = @"Not sent"; break; } [self dismissModalViewControllerAnimated:YES]; } -(void)launchMailAppOnDevice { NSString *recipients = @""; NSString *body = @""; NSString *email1 = [NSString stringWithFormat:@"%@%@", recipients, body]; email1 = [email1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email1]]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload