【问题标题】:MFMessageComposeViewController freezes before displaying the view controllerMFMessageComposeViewController 在显示视图控制器之前冻结
【发布时间】:2015-12-08 04:25:21
【问题描述】:

我遇到了一个问题,每次我单击调用我的MFMessageComposeViewController 的按钮时都没有任何反应。更具体地说,它在显示控制器之前冻结,我无法做任何事情。

这是我的代码:

- (IBAction)getQuote:(id)sender {
    NSString * inputProduct =_productTextField.text;
    NSString * inputYear = _yearTextField.text;
    NSString * inputMake = _makeTextField.text;
    NSString * inputEmail = email.text;
    NSString * inputDescript = _descript.text;
    emailConfirmation.text = email.text;
    //email subject
    NSString *emailTitle = @"Love Shack Electronics";
    //email content
    if ([conditionlabel  isEqual: @"Fair"]) {
        NSString *emailBody = [NSString stringWithFormat:@"Product:%@    Make:%@   Year Manufactured:%@  Description:%@  Condition:Fair Email:%@",inputProduct,inputMake,inputYear,inputDescript, inputEmail];
        NSArray *recipient = [NSArray arrayWithObject:@"LoveShackElectronics@gmail.com"];
        MFMailComposeViewController *SuperLovedEmail = [[MFMailComposeViewController alloc]init];
        [SuperLovedEmail setTitle:emailTitle];
        [SuperLovedEmail setToRecipients:recipient];
        [SuperLovedEmail setMessageBody:emailBody isHTML:NO];
        [SuperLovedEmail setUserActivity:false];
        [self presentViewController:SuperLovedEmail animated:YES completion:nil];
        [SuperLovedEmail setEditing:false];

如果有人可以帮助或找出我的代码有什么问题,将不胜感激。

【问题讨论】:

  • 您是在模拟器还是设备中运行您的应用程序?
  • 在哪里检查您是否可以使用电子邮件?
  • 你为什么打电话给[SuperLovedEmail setEditing:false];?不要那样做。
  • @rmaddy 就像我说的,我对 xcode 和 Objective-C 很陌生。我将如何检查我是否可以使用电子邮件?
  • 首先阅读MFMailComposeViewController 的文档。它告诉你怎么做。

标签: ios objective-c mfmailcomposeviewcontroller


【解决方案1】:

请检查设备和最新的 Xcode 版本。它工作正常。它不起作用然后放入如下调度方法

 dispatch_async(dispatch_get_main_queue(), 
^{

    if ([conditionlabel  isEqual: @"Fair"]) 
{
            NSString *emailBody = [NSString stringWithFormat:@"Product:%@    Make:%@   Year Manufactured:%@  Description:%@  Condition:Fair Email:%@",inputProduct,inputMake,inputYear,inputDescript, inputEmail];
            NSArray *recipient = [NSArray arrayWithObject:@"LoveShackElectronics@gmail.com"];
            MFMailComposeViewController *SuperLovedEmail = [[MFMailComposeViewController alloc]init];
            [SuperLovedEmail setTitle:emailTitle];
            [SuperLovedEmail setToRecipients:recipient];
            [SuperLovedEmail setMessageBody:emailBody isHTML:NO];
            [SuperLovedEmail setUserActivity:false];
            [self presentViewController:SuperLovedEmail animated:YES completion:nil];
            [SuperLovedEmail setEditing:false];
              }
});

【讨论】:

    猜你喜欢
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 1970-01-01
    • 2011-02-12
    • 2015-08-29
    • 1970-01-01
    • 2012-05-04
    相关资源
    最近更新 更多