本文介绍了MFMessageComposeViewController不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的方法,该方法获取一个参数,然后发送一条消息.它不起作用.
I have a simple method that gets one argument and then sends a message. It is not working.
代码:
- (void)sendSMS:(NSString *)text {
MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
viewController.body = text;
viewControllerM.mailComposeDelegate = self;
[self presentViewController:viewController animated:YES completion:nil];
}
怎么了?
推荐答案
您需要设置委托:
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];
}
这篇关于MFMessageComposeViewController不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!