1

我使用下面的代码发送邮件:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"my title"];
NSMutableString *emailBody = [[NSMutableString alloc] initWithString:  @"Hi\n\n"];
[emailBody appendString: @"test"];  
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
[emailBody release];

该代码在旧操作系统版本(Base SDK 5.0,部署目标 4.0)上运行良好。我刚刚升级到 Xcode 4.5,以 iOS 6.0 作为基础 SDK,部署目标仍然是 4.3,并且代码在 5.0、5.1 和 6.0 的模拟器上仍然运行良好。

现在我使用 iOS 4.3.3 将应用程序安装到 iPad。MFMailComposeViewController没有出现,它占用并且应用程序停止工作。我检查了设备日志,它显示:

Incident Identifier: 53CF815B-36FB-4523-8E58-03D80E6BD2D6
CrashReporter Key:   e1ce74069fc4d91cdf244ef60282649f2ea4716e
Hardware Model:      iPad1,1
Process:         MyApp [1018]
Path:            /var/mobile/Applications/75088803-4768-4CD6-A561-553F4A182229/MyApp.app/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-11-16 14:29:59.959 +0800
OS Version:      iPhone OS 4.3.3 (8J3)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  0

Application Specific Information:
MyApp[1018] has active assertions beyond permitted time: 
{(
    <SBProcessAssertion: 0x1fa0dd00> identifier: Suspending process: MyApp[1018] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:30 preventSuspend  preventThrottleDownCPU  preventThrottleDownUI 
)}

Elapsed total CPU time (seconds): 0.770 (user 0.460, system 0.310), 8% CPU 
Elapsed application CPU time (seconds): 0.000, 0% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x332e5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332e5758 mach_msg + 44
2   AppSupport                      0x33bbb7b8 CPDMTwoWayMessage + 164
3   AppSupport                      0x33bba530 -[CPDistributedMessagingCenter _sendMessage:userInfoData:oolKey:oolData:makeServer:receiveReply:nonBlocking:error:] + 352
4   AppSupport                      0x33bba0b2 -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:nonBlocking:] + 618
5   AppSupport                      0x33bb91ae -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:] + 58
6   AppSupport                      0x33bb9312 -[CPDistributedMessagingCenter sendMessageAndReceiveReplyName:userInfo:] + 42
7   MessageUI                       0x3693c1fa _CallMessageUIServiceMethod + 182
8   MessageUI                       0x3693c01e +[MFMailAccountProxy reloadAccounts] + 22
9   MessageUI                       0x3693bf6c +[MFMailComposeController _refreshMailAccountsIfNecessary] + 32
10  MessageUI                       0x3693bf2a +[MFMailComposeController isSetupForDelivery] + 10
11  MessageUI                       0x3693be80 +[MFMailComposeViewController canSendMail] + 24
12  MessageUI                       0x3693bc36 -[MFMailComposeViewController initWithComposition:contentSize:mailComposeControllerOptions:] + 42
13  MessageUI                       0x3693bbf8 -[MFMailComposeViewController initWithComposition:] + 28
14  MessageUI                       0x36963fac -[MFMailComposeViewController initWithNibName:bundle:] + 44
15  UIKit                           0x329e8a0c -[UIViewController init] + 12
16  MyApp                       0x000d09ee 0xb5000 + 113134
17  MyApp                       0x000e3820 0xb5000 + 190496
18  UIKit                           0x32ad1036 -[UIActionSheet(Private) _buttonClicked:] + 186
19  CoreFoundation                  0x32dc956a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
20  UIKit                           0x329ceec2 -[UIApplication sendAction:to:from:forEvent:] + 78
21  UIKit                           0x329cee62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
22  UIKit                           0x329cee34 -[UIControl sendAction:to:forEvent:] + 32
23  UIKit                           0x329ceb86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350
24  UIKit                           0x329cf41c -[UIControl touchesEnded:withEvent:] + 336
25  UIKit                           0x329cdbee -[UIWindow _sendTouchesForEvent:] + 362
26  UIKit                           0x329cd568 -[UIWindow sendEvent:] + 256
27  UIKit                           0x329b630c -[UIApplication sendEvent:] + 292
28  UIKit                           0x329b5c4c _UIApplicationHandleEvent + 5084
29  GraphicsServices                0x35c8ee70 PurpleEventCallback + 660
30  CoreFoundation                  0x32e30a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
31  CoreFoundation                  0x32e32838 __CFRunLoopDoSource1 + 160
32  CoreFoundation                  0x32e33606 __CFRunLoopRun + 514
33  CoreFoundation                  0x32dc3ebc CFRunLoopRunSpecific + 224
34  CoreFoundation                  0x32dc3dc4 CFRunLoopRunInMode + 52
35  GraphicsServices                0x35c8e418 GSEventRunModal + 108
36  GraphicsServices                0x35c8e4c4 GSEventRun + 56
37  UIKit                           0x329e0d62 -[UIApplication _run] + 398
38  UIKit                           0x329de800 UIApplicationMain + 664
39  MyApp                       0x000c95a4 0xb5000 + 83364
40  MyApp                       0x000b73b8 0xb5000 + 9144

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x332e8fbc kevent + 24
1   libdispatch.dylib               0x33abc032 _dispatch_mgr_invoke + 706
2   libdispatch.dylib               0x33abd03a _dispatch_queue_invoke + 86
3   libdispatch.dylib               0x33abc5ea _dispatch_worker_thread2 + 186
4   libsystem_c.dylib               0x363d958a _pthread_wqthread + 258
5   libsystem_c.dylib               0x363d9bbc start_wqthread + 0

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x332e5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332e5758 mach_msg + 44
2   CoreFoundation                  0x32e312b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x32e33562 __CFRunLoopRun + 350
4   CoreFoundation                  0x32dc3ebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x32dc3dc4 CFRunLoopRunInMode + 52
6   WebCore                         0x31e5c27e RunWebThread(void*) + 382
7   libsystem_c.dylib               0x363d830a _pthread_start + 242
8   libsystem_c.dylib               0x363d9bb4 thread_start + 0

欢迎任何评论。

4

1 回答 1

1

堆栈跟踪看起来这不是您的错,它是系统代码挂起并导致您的应用程序被杀死。开发者论坛中有一个帖子(非公开链接,抱歉)表明这可能与系统 Mail.app 相关联。

我会尝试重新启动设备和类似的技巧,但最终你的应用程序在 4.3 上可能仍然不稳定。你真的需要支持4.3吗?

于 2012-11-16T07:36:18.920 回答