iphone - 在设备上进行测试时向SIGABRT发出信号,它可在模拟器上运行。简易代码

标签 iphone ios xcode ipad xcode4

我没有编程经验。

我试图做一个简单的iOS应用(只是尝试一些教程),可以作为“发送邮件”使用

简单的界面,仅需按下一个按钮,即可打开MFMailComposeViewController窗口。

那就是代码。

ViewController.h

#import <UIKit/UIKit.h>
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MessageUI.h>


@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>

-(IBAction)showPicker:(id)sender;

@end

ViewController.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”的位置。

有小费吗?

预先感谢大家。

最佳答案

尝试两件事:

  • 清理文件<SHIFT+CMD+K>
  • 从设备上卸载文件,然后尝试使用清理过的
  • 关于iphone - 在设备上进行测试时向SIGABRT发出信号,它可在模拟器上运行。简易代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13365514/

    相关文章:

    ios - 在 UITableView 中选择时无法更改分隔符(自定义 UIView)颜色

    iphone - 自定义UISearchBar

    ios - 带有 UITableViewController 的 SearchBar 包含错误数量的单元格

    ios - Xcode、Git、Jenkins、PhoneGap 1.5.0 构建错误

    ios - Swift - XCode6 beta5 每个类都需要 init(coder)

    ios - 使用 Cocoapods 的 Xcode 7 UI 测试在设备上失败

    ios - 使用自动布局将 UITableView 的高度设置为其内容的高度

    iphone - 如何从 DER/PEM 文件获取 SecKeyRef

    iphone - 调试 iPhone 应用程序

    ios - 显示带有滚动选项的所有选项卡(在屏幕上应该只有 4 个选项卡)