2

我想从另一个在后台执行的类方法中 弹出MFMessageCompose模型(topviewcontroller) 。NSObject

MFMessageCompose我使用此代码弹出模型:

MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
    controller.body = @"Check out FundooSpace for mobile.Download it now from app.fundoospace.net/FundooSpace/d";
    controller.recipients = (NSArray *)passa;
    passa = nil;
    AppDelegate * appDelegateObject1 = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    controller.messageComposeDelegate = self;
    [appDelegateObject1.navigationCntr.topViewController presentModalViewController:controller animated:NO];
}

它工作正常。但是当我点击发送或取消按钮时,应用程序崩溃并给出错误是

wait_fences: failed to receive reply: 10004003

请建议我。

4

1 回答 1

0

我完全检查了您在问题中包含的代码,对我来说它在设备上运行良好。

1)确保在您的 .h 中有委托

@interface ViewController : UIViewController <MFMessageComposeViewControllerDelegate>

2)您还必须在您的.m中实现委托方法:

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    NSLog(@"didFinishWithResult");

    // you have to deal with the result var

    switch (result) {
        case MessageComposeResultCancelled:
            NSLog(@"Cancelled");
            break;
        case MessageComposeResultFailed:
            UIAlertView *alert = [[UIAlertView alloc] 
                          initWithTitle:@"MyApp" 
                                message:@"Unknown Error"
                               delegate:self 
                      cancelButtonTitle:@”OK” 
                      otherButtonTitles:nil];
            [alert show];
            [alert release];
            break;
        case MessageComposeResultSent:

            break;
        default:
            break;
    }

    [self dismissModalViewControllerAnimated:YES];
}

3) 如果您在 >iOS6.0 上,“旧” presentModalViewController:animated已被弃用,因此更改为presentViewController:animated:completion:因为 Xcode 也表明了这一点。

于 2013-04-23T14:02:40.597 回答