MFMessageComposeViewController在ios8上没有显示发送按钮和消息正文,当点击收件人列表键盘出现并发送按钮时,消息体显示出来。以下是消息功能的代码:
MFMessageComposeViewController *msgController = [[MFMessageComposeViewController alloc] init] ;
if([MFMessageComposeViewController canSendText])
{
if (msgController)
{
msgController = nil;
msgController = [[MFMessageComposeViewController alloc] init] ;
}
NSString *messageBody =@"helloWorld";
msgController.body = messageBody;
msgController.recipients = numberArray;
msgController.messageComposeDelegate = (id)self;
[self presentViewController:msgController animated:YES completion:^{}];
提前致谢。
答案 0 :(得分:1)
首先将MessageUI框架添加到您的应用程序框架,然后
#import <MessageUI/MessageUI.h>
@interface class()
<MFMailComposeViewControllerDelegate>
{
....
}
@end
然后在你的类实现中写
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
[mail setMailComposeDelegate:self];
[mail setSubject:@"Subject goes here..."];
[mail setMessageBody:@"Message body goes here..." isHTML:NO];
[self presentViewController:mail animated:YES completion:NULL];
}
并实现MFMailcomposeViewController的委托,如
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[controller dismissViewControllerAnimated:YES completion:nil];
}
答案 1 :(得分:0)
正文中应该有收件人和一些信息以启用&#34;发送&#34;按钮。
以下是供参考的链接:
http://iosdevelopertips.com/core-services/how-to-send-an-sms-progammatically.html
希望这有帮助!