MFMessageComposeViewController not working

谁都会走 提交于 2019-12-10 15:45:05

问题


I have a simple method that gets one argument and then sends a message. It is not working.

Code:

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

What's wrong?


回答1:


You need to set the delegate:

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];
    }


来源:https://stackoverflow.com/questions/14532747/mfmessagecomposeviewcontroller-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!