我是 iphone 开发的新手。我正在构建一个可以发送电子邮件的应用程序。我正在使用以下代码
- (IBAction)btnsendPressAction:(id)sender {
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *mailer=[[MFMailComposeViewController alloc]init];
mailer.mailComposeDelegate=self;
[mailer setSubject:@"A Message for testing"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"rajshetty2125@gmail.com", @"secondMail@example.com", nil];
[mailer setToRecipients:toRecipients];
UIImage *image=[UIImage imageNamed:@"logo.png"];
NSData *imageData=UIImagePNGRepresentation(image);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"logo.png"];
NSString *emailBody=@"This is test email";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
mailer.modalPresentationStyle = UIModalPresentationPageSheet ;
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"failure" message:@"Alert" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
我的问题是 mailComposeController 委托没有被调用,我无法通过我的应用程序发送电子邮件。我经历了许多链接,但每个地方我都找到了相同的方法。谁可以帮我这个事 ?