Tôi gặp sự cố lạ sau khi gọi "[MFMailComposeViewController canSendMail]".Tại sao MFMailComposeViewController gặp sự cố?
Tôi không thể tạo lại nó, nó từ iTunesConnect. Phương thức đó (canSendMail) đang được gọi từ chủ đề chính, và tại thời điểm đó, tôi không làm bất cứ điều gì với sổ địa chỉ.
Bất kỳ ý tưởng/đề xuất nào sẽ được đánh giá rất cao.
Cảm ơn trước!
Lưu ý: Điều này đã xảy ra trong iOS 5.1.1.
Exception Type: SIGABRT
Exception Codes: #0 at 0x3583232c
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3583232c __pthread_kill + 8
1 libsystem_c.dylib 0x347e729f abort + 95
2 AppSupport 0x3133cc57 abortAfterFailingIntegrityCheck + 39
3 AppSupport 0x3133ceef runIntegrityCheckAndAbort + 535
4 AppSupport 0x3133d025 checkResultWithStatement + 113
5 AppSupport 0x3133ea13 _connectAndCheckVersion + 1059
6 AppSupport 0x3133eab7 CPSqliteDatabaseConnectionForWriting + 43
7 AppSupport 0x3133eb8d CPSqliteDatabaseRegisterFunction + 21
8 AddressBook 0x337873f7 ABCDBContextCreateWithPathAndAddressBook + 215
9 AddressBook 0x3377b429 ABCCreateAddressBookWithDatabaseDirectoryAndForceInProcessMigrationInProcessLinkingAndResetSortKeys + 233
10 AddressBook 0x33789cd7 ABAddressBookCreate + 15
11 Message 0x31072453 MFThreadLocalAddressBook + 87
12 MessageUI 0x313a5471 +[MFMailComposeController initialize] + 9
13 libobjc.A.dylib 0x35edc973 _class_initialize + 239
14 libobjc.A.dylib 0x35edc87b prepareForMethodLookup + 143
15 libobjc.A.dylib 0x35edc747 lookUpMethod + 47
16 libobjc.A.dylib 0x35edc713 _class_lookupMethodAndLoadCache3 + 19
17 libobjc.A.dylib 0x35edbfcb objc_msgSend_uncached + 27
18 MessageUI 0x313a5455 +[MFMailComposeViewController canSendMail] + 33
=============
UPDATE:
Đoạn mã gây ra vụ tai nạn này là như sau:
-(IBAction)helpButtonPressed
{
if([MFMailComposeViewController canSendMail])
{
NSString* mail = self.feedbackSettings[@"mail"];
NSString* title = self.feedbackSettings[@"title"];
MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
mailComposer.toRecipients = @[ mail ];
mailComposer.subject = title;
[self presentViewController:mailComposer animated:YES completion:nil];
[mailComposer release], mailComposer = nil;
}
else
{
[UIAlertView showAlertViewWithTitle:nil message:NSLocalizedString(@"Please, setup a mail account in your phone first.", nil) buttonTitle:NSLocalizedString(@"OK", nil)];
}
}
Có thể bạn đang cố trình bày 'MFMailComposeViewController' khi' canSendEmail' trả về 'NO'. – jamapag
Bạn có thể đính kèm đoạn mã nơi bạn tạo 'MFMailComposeViewController' không? – jamapag
Không, tôi không cố gắng trình bày MFMailComposeViewController khi canSendEmail là KHÔNG. Tôi sẽ cập nhật câu hỏi, cảm ơn. –