我有一個支持iOS 5和iOS 6的應用程序。 MFMailComposeViewController在iOS 6中正常工作,但是當用戶嘗試編輯正文時iOS 5出現崩潰的電子郵件。所有其他領域可以編輯沒有任何問題。 有人看到這個問題嗎?當試圖編輯iOS 5中的電子郵件正文時,MFMailComposeViewController崩潰
的代碼如下:
// 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];
}
崩潰日誌如下所示:
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
只是澄清MFComposeTextContentView是MFMailComposeViewController中的一個對象。實例0x8d6b880的確是MFComposeTextContentView。無論出於何種原因,獲取導致崩潰的選擇器setInputAccessoryView。所有這些都發生在MFMailComposeViewController類的內部。 – Sergio