0

iOS 5 및 iOS 6 모두를 지원하는 앱이 있습니다. MFMailComposeViewController는 iOS 6에서 정상적으로 작동하지만 사용자가 본문을 편집하려고하면 iOS 5에서 충돌이 발생합니다. 이메일의 다른 모든 필드는 문제없이 편집 할 수 있습니다. 이 문제를 본 사람이 있습니까? 당신이iOS 5에서 이메일 본문을 편집 할 때 MFMailComposeViewController가 충돌 함

2 MFMailComposeViewController가 포함 된 장치에서이 작업을 수행하려고하면

Crashed Thread: 0 

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 

Application Specific Information: 
iPhone Simulator 358.4, iPhone OS 5.1 (iPhone/9B176) 

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MFComposeTextContentView setInputAccessoryView:]: unrecognized selector sent to instance 0x8d6b880' 
*** First throw call stack: 
(0x1da6022 0x1b19cd6 0x1da7cbd 0x1d0ced0 0x1d0ccb2 0x5e4b1 0xb5aa29 0x1d71855 0x1d71778 0xa9f19a 0xaabb03 0x49e084 0x169a798 0x4658fb 0x4675f8 0x45fe29 0x45f133 0x4603bf 0x462a21 0x46297c 0x45b3d7 0x1c01a2 0x1c0532 0x1a6dc4 0x19a634 0x1f39ef5 0x1d7a195 0x1cdeff2 0x1cdd8da 0x1cdcd84 0x1cdcc9b 0x1f387d8 0x1f3888a 0x198626 0x303d 0x2f65) 

abort() called 

Thread 0 Crashed: 
0 libsystem_kernel.dylib   0x99b6e9c6 __pthread_kill + 10 
1 libsystem_c.dylib    0x991a5f78 pthread_kill + 106 
2 libsystem_c.dylib    0x99196bdd abort + 167 
3 libc++abi.dylib     0x027dee78 abort_message + 50 
4 libc++abi.dylib     0x027dc89e _ZL17default_terminatev + 34 
5 libobjc.A.dylib     0x01b19f17 _objc_terminate + 94 
6 libc++abi.dylib     0x027dc8de _ZL19safe_handler_callerPFvvE + 13 
7 libc++abi.dylib     0x027dc946 std::terminate() + 23 
8 libc++abi.dylib     0x027ddb3e __cxa_rethrow + 83 
9 libobjc.A.dylib     0x01b19e15 objc_exception_rethrow + 47 
10 CoreFoundation     0x01cdcde0 CFRunLoopRunSpecific + 304 
11 CoreFoundation     0x01cdcc9b CFRunLoopRunInMode + 123 
12 GraphicsServices    0x01f387d8 GSEventRunModal + 190 
13 GraphicsServices    0x01f3888a GSEventRun + 103 
14 UIKit       0x00198626 UIApplicationMain + 1163 
15 SomeXYZApp      0x0000303d main + 141 (main.m:16) 
16 SomeXYZApp      0x00002f65 start + 53 
+0

MFComposeTextContentView는 MFMailComposeViewController 내의 개체입니다. 인스턴스 0x8d6b880은 실제로 MFComposeTextContentView입니다. 어떤 이유로 든 충돌을 일으키는 selector 인 setInputAccessoryView를 얻는 중입니다. 이 모든 일은 MFMailComposeViewController 클래스의 내부에서 발생합니다. – Sergio

답변

1

1 메일 계정을 만들고 다음과 같이

// Displays an email composition interface inside the application. Populates all the Mail fields. 
-(void)displayMailComposerSheet { 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

    [picker setSubject:@"xyz"]; 

    NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
    [picker setToRecipients:toRecipients]; 

    [picker setMessageBody:@"xyz" isHTML:NO]; 

    // Deprecated in iOS 6.0: 
    [self presentModalViewController:picker animated:YES]; 
} 

// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the 
// message field with the result of the operation. 
- (void)mailComposeController:(MFMailComposeViewController*)controller 
      didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 

    // Deprecated in iOS 6.0: 
    [self dismissModalViewControllerAnimated:YES]; 
} 

충돌 로그 보이는 다음과 같이

코드는 메론 "canSendMail이므로 시도해 볼 수 있습니다.

if ([MFMailComposeViewController canSendMail]) { 
// create mail 
} else { 
// error message 
} 

3 시도는 메인 스레드에서 컨트롤러를 호출 :

dispatch_async(dispatch_get_main_queue(), ^{ 
    //call MFMailComposeViewController 
}); 
+0

1 단계와 2 단계는 이미 내 코드의 일부입니다. 3 단계를 시도했지만 변경되지 않았습니다. MailCompose 뷰를 얻었습니다. 첫 번째 응답자가 잘못된 개체로 전송 된 것처럼 전자 메일 본문을 편집하려고 할 때 충돌이 발생합니다. – Sergio

0

당신이 작은 일을 잊고있을 수 있습니다 다시 시도 ... 난 그 ABT 잘 모르겠습니다 ..... 당신이 코드는 괜찮 은데 .... 그것은 MFMaileComposeViewControllerDelegate

@interface MailViewController : UIViewController <MFMailComposeViewControllerDelegate> 
0 .. 작동

먼저 추가하고 가져 오기 MessageUI 프레임 워크

#import <MessageUI/MessageUI.h> 

및 선언한다

메일

- (IBAction)openMail:(id)sender 
{ 
if ([MFMailComposeViewController canSendMail]) 
{ 
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 

    mailer.mailComposeDelegate = self; 

    [mailer setSubject:@"xyz"]; 

    NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
    [mailer setToRecipients:toRecipients]; 

    NSString *emailBody = @"xyz"; 

    [mailer setMessageBody:emailBody isHTML:NO]; 

    [self presentModalViewController:mailer animated:YES]; 

    [mailer release]; 
} 
else 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                message:@"Your device doesn't support the composer sheet" 
                delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles: nil]; 
    [alert show]; 
    [alert release]; 
} 

}

을 보내기 위해이 코드를 작성하고 또한 내가 문제를 발견 MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued."); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"Mail saved: you saved the email message in the drafts folder."); 
      break; 
     case MFMailComposeResultSent: 
      NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send."); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error."); 
      break; 
     default: 
      NSLog(@"Mail not sent."); 
      break; 
    } 

     // Remove the mail view 
    [self dismissModalViewControllerAnimated:YES]; 
} 
+0

아니요. 이것은 기본적으로 내가 가지고있는 것입니다. 앞서 언급했듯이 MailComposer보기가 표시됩니다. 그래서 모든 수표와 잔액이 완료되었습니다. 이메일의 본문을 제외한보기의 모든 항목을 탭할 수 있습니다. 본문이 변경되지 않은 경우 이메일을 보낼 수도 있습니다. 사람이 시체를 편집하려고 시도 할 때만 앱이 다운되며 이는 iOS 5를 실행하는 기기에서만 발생합니다. – Sergio

+0

이메일 본문에 ........ 무엇을 표시하고 있습니까? 그것은 HTML 또는 간단한 텍스트 ....입니까? – Wolverine

+0

그리고 ARC를 사용하고 있습니까 ..? – Wolverine

0

의 대리자 메서드를 작성합니다. DAKeyboardControl을 사용하여 키보드의 스크롤을 해제 할 수 있습니다 (GitHub for DA's KeyboardControl 참조).

DA 코드의 responderDidBecomeActive가 MFMailComposeViewController를 통해 호출되면 textField는 inputAccessoryView에 응답하지 않는 MFComposeTextContentView 객체를받습니다. 이것은 지원되지 않는 상호 작용 인 것 같습니다. 그러나 iOS 6에서는 DA의 오버로드 된 클래스가 MFMailComposeViewController에 의해 호출되지 않으므로이 문제가 발생하지 않습니다.

DAKeyboardControl 지원이 제거되면 모든 것이 올바르게 작동합니다.

+0

다니엘 코드의 최신 버전이이 문제를 해결합니다. 다니엘 감사합니다! – Sergio

1

같은 문제가있었습니다. IOS6에서만, IOS5.1에서는 그렇지 않습니다. 테스트 결과 양식이 제대로 해제되지 않았다는 것을 알게되었습니다. 따라서 폼을 강제로 릴리스하는 코드를 추가했습니다. 그건 내 경우에 효과가 있었어. 희망이 당신을 도울 수 있습니다.

-(void) sendMail:(NSString *) mailTo 
{ 
    // Check if you can send an e-mail 
    if ([MFMailComposeViewController canSendMail]) 
    { 
     @try 
     { 
      // show the form 
      MFMailComposeViewController *mailForm = nil; 
      mailForm = [[MFMailComposeViewController alloc] init]; 
      mailForm.mailComposeDelegate = self; 
      [mailForm setToRecipients:@[ mailTo ]]; 
      mailForm.modalPresentationStyle = UIModalPresentationFormSheet; 
      mailForm.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
      [self presentModalViewController:mailForm animated:YES]; 
     } 

     @catch (NSException *exception) 
     { 
      // Show what went wrong 
      NSString *fout = [[NSString alloc] initWithFormat:@"%@: %@",[exception name], [exception reason]]; 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Mailer" message:fout delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
      [alert show]; 
     } 
    } 
    else 
    { 
     // Inform the user you cannot send mail, no mailbox set 
     [self noEmailAccountMeansNoEmail]; 
    } 
} 

- (void)mailComposeController:(MFMailComposeViewController*)mailForm didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    // Get the mail form off the screen 
    if ((mailForm != nil)) 
     [mailForm dismissModalViewControllerAnimated:YES]; 

    // Force release/dealloc of the screen 
    mailForm = nil; 
    return; 
} 
관련 문제