Я новичок в разработке 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:@"[email protected]", @"[email protected]", 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 не вызывается, и я не могу отправить электронное письмо через свое приложение. Я прошел через множество ссылок, но везде я нашел один и тот же метод. Может ли кто-нибудь помочь мне в этом?