Par*_*att 1 iphone cocoa-touch objective-c ios4
当我尝试在设备上使用MFMailComposeViewController时,我得到以下给出的崩溃日志.
当我尝试在模拟器上运行它时,它会打开模态视图.
这是我正在使用的代码:
stringHTML并且html是HTML字符串.
stringHTML是NSString html类型,类型为NSMutableString.
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:@"Email"];
NSLog(@"%@",html);
NSString *stringHTML=html;
NSLog(@"%@",stringHTML);
[mailController setMessageBody:stringHTML isHTML:YES];
[self presentModalViewController:mailController animated:YES];
[mailController release];
Run Code Online (Sandbox Code Playgroud)
可能有什么不对?
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <QuizReportsView: 0x411af0>.'
*** Call stack at first throw:
(
0 CoreFoundation 0x3737364f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x33a30c5d objc_exception_throw + 24
2 UIKit 0x31350fcf -[UIViewController presentModalViewController:withTransition:] + 546
3 UIKit 0x31350cd7 -[UIViewController presentModalViewController:animated:] + 58
4 Vocab 0x0007d1bf -[QuizReportsView actionSheet:clickedButtonAtIndex:] + 270
5 UIKit 0x313c603d -[UIActionSheet(Private) _buttonClicked:] + 192
6 CoreFoundation 0x372e3571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
7 UIKit 0x312c3ec9 -[UIApplication sendAction:to:from:forEvent:] + 84
8 UIKit 0x312c3e69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
9 UIKit 0x312c3e3b -[UIControl sendAction:to:forEvent:] + 38
10 UIKit 0x312c3b8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
11 UIKit 0x312c4423 -[UIControl touchesEnded:withEvent:] + 342
12 UIKit 0x312c2bf5 -[UIWindow _sendTouchesForEvent:] + 368
13 UIKit 0x312c256f -[UIWindow sendEvent:] + 262
14 UIKit 0x312ab313 -[UIApplication sendEvent:] + 298
15 UIKit 0x312aac53 _UIApplicationHandleEvent + 5090
16 GraphicsServices 0x31c36e77 PurpleEventCallback + 666
17 CoreFoundation 0x3734aa97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
18 CoreFoundation 0x3734c83f __CFRunLoopDoSource1 + 166
19 CoreFoundation 0x3734d60d __CFRunLoopRun + 520
20 CoreFoundation 0x372ddec3 CFRunLoopRunSpecific + 230
21 CoreFoundation 0x372dddcb CFRunLoopRunInMode + 58
22 GraphicsServices 0x31c3641f GSEventRunModal + 114
23 GraphicsServices 0x31c364cb GSEventRun + 62
24 UIKit 0x312d5d69 -[UIApplication _run] + 404
25 UIKit 0x312d3807 UIApplicationMain + 670
26 Vocab 0x00002223 main + 82
27 Vocab 0x000021cc start + 40
)
terminate called after throwing an instance of 'NSException'
Run Code Online (Sandbox Code Playgroud)
Rah*_*yas 11
试试这个
//check if device is configured to send mails
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
if(mailController)
{
mailController.mailComposeDelegate = self;
[mailController setSubject:@"Email"];
NSLog(@"%@",html);
NSString *stringHTML=html;
NSLog(@"%@",stringHTML);
[mailController setMessageBody:stringHTML isHTML:YES];
[self presentModalViewController:mailController animated:YES];
[mailController release];
}
}
Run Code Online (Sandbox Code Playgroud)
从错误很明显,您正在呈现nil 模态视图控制器.
检查MFMailComposeViewController是否正确构造它的对象 .
和Aslo MFMailComposeViewController在iOS 3.0及更高版本中可用.
尝试使用以下代码
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
if(mailController)
{
mailController.mailComposeDelegate = self;
[mailController setSubject:@"Email"];
NSLog(@"%@",html);
NSString *stringHTML=html;
NSLog(@"%@",stringHTML);
[mailController setMessageBody:stringHTML isHTML:YES];
[self presentModalViewController:mailController animated:YES];
[mailController release];
}
Run Code Online (Sandbox Code Playgroud)
有关下面的更多信息
| 归档时间: |
|
| 查看次数: |
2146 次 |
| 最近记录: |