2014-11-18 4 views
1

IOS 응용 프로그램에 IOS를 실행하는 버튼이 있습니다. 6,7 IOS 8을 실행하는 장치에서 이 제대로 작동하지만 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]; 
} 
도움이 될 수 있습니다
관련 문제