我没有编程经验。
我正在尝试做一个简单的 iOS 应用程序(只是为了尝试一些教程),它可以作为“sendmail”使用
简单的界面,只有 1 个按钮,当按下时,它会打开 MFMailComposeViewController 窗口。
这就是代码。
视图控制器.h
#import <UIKit/UIKit.h>
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MessageUI.h>
@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>
-(IBAction)showPicker:(id)sender;
@end
视图控制器.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(IBAction)showPicker:(id)sender
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"example@example.com"];
[picker setToRecipients:toRecipients];
[picker setSubject:@"TEST SUBJECT"];
[self presentViewController:picker animated:YES completion:nil];
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
在 iPhone 和 iPad 模拟器上,它就像一个魅力。但是在设备上对其进行测试时,它会崩溃并给出信号 SIGABRT 并显示 main.m 的一部分作为证据:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
附近有“线程 1 - 信号 SIGABRT”。
任何提示?
提前感谢大家。