MFMessageComposeViewController在显示视图控制器之前冻结

时间:2015-12-08 04:25:21

标签: ios objective-c mfmailcomposeviewcontroller

我遇到问题,每次点击调用我的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];

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

1 个答案:

答案 0 :(得分:-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];
              }
});