2014-11-18 2 views
1

У моего приложения IOS есть кнопка для отправки электронной почты - работает на IOS 6,7, она отлично работает, но на устройствах под управлением IOS 8 открывается электронное письмо, в приложении или журналах ошибки не появляется, но письмо не принимаетсяIOS 8: не отправляет электронные письма

Я искал его, а также посмотрел на сайт яблока, а также другие учебники. Я не вижу различий от того, что я написал ... любые идеи?

- (IBAction) emailBtn_Click:(id)sender 
{ 
    MFMailComposeViewController *emailComposer = [[MFMailComposeViewController alloc] init]; 
    emailComposer.mailComposeDelegate = self; 
    if ([MFMailComposeViewController canSendMail] == YES) 
    { 
     [emailComposer setSubject:@"hi"]; 
     [emailComposer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 

     [self presentViewController:emailComposer animated:YES completion:NULL]; 
    } 
    else 
    { 
     NSLog(@"Can't Open Email"); 
    } 
} 

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 
{ 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      NSLog(@"e-mail cancelled"); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"e-mail saved"); 
      break; 
     case MFMailComposeResultSent: 
      NSLog(@"e-mail sent"); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"e-mail sent failure: %@", [error localizedDescription]); 
      break; 
     default: 
      break; 
    } 

    [self dismissViewControllerAnimated:YES completion:NULL]; 
} 

ответ

0

использовать этот код, может помочь вам

- (IBAction) emailBtn_Click:(id)sender 
{ 

if([self canDeviceSendEmail]) 
{ 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.modalPresentationStyle=UIModalPresentationFullScreen; 
    picker.mailComposeDelegate = self; 
    [picker setSubject:@"Report"]; 
    [picker setTitle:@""]; 
    NSString *emailBody = [NSString stringWithString:@"Message"]; 
    [picker setMessageBody:emailBody isHTML:YES]; 
    [picker setToRecipients:[NSArray arrayWithObject:@""]]; 
    [picker setCcRecipients:[NSArray arrayWithObject:@""]]; 

    [self presentViewController:picker animated:YES completion:^{ 


    }]; 
} 
else{ 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil 
                message:@"You must have an email account configured to use this feature." 
                delegate:nil 
              cancelButtonTitle:@"Ok" 
              otherButtonTitles:nil,nil]; 
    [alert show]; 
} 

} 

-(void)mailComposeController:(MFMailComposeViewController*)controller 
    didFinishWithResult:(MFMailComposeResult)result 
        error:(NSError*)error { 

//[self dismissModalViewControllerAnimated:YES]; 
[self dismissViewControllerAnimated:YES completion:^{ 

}]; 
} 
- (BOOL)canDeviceSendEmail{ 
Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); 
return mailClass != nil && [mailClass canSendMail]; 
} 
Смежные вопросы