4

我有一个简单的方法,它获取一个参数然后发送一条消息。它不工作。

代码:

- (void)sendSMS:(NSString *)text {
    MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
    viewController.body = text;
    viewControllerM.mailComposeDelegate = self;
    [self presentViewController:viewController animated:YES completion:nil];
}

怎么了?

4

1 回答 1

4

您需要设置委托:

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
    if([MFMessageComposeViewController canSendText])
    {
        controller.body = @"YO";
        controller.recipients = [NSArray arrayWithObjects:@"5625555555", nil];
        controller.messageComposeDelegate = self;

        [self presentViewController:controller animated:YES completion:nil];
    }
于 2013-01-26T01:13:35.403 回答