跳转到手机短信编辑界面
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
if ([messageClass canSendText]) {//首先判断手机是否能进行编辑
//打开手机的短信编辑控制器
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
//传出去的分享内容
picker.body = [NSString stringWithFormat:@"%@",showmeg];
[self presentViewController:picker animated:YES completion:nil];
} else {
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"当前设备暂时没有办法发送短信" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
[myAlertView show];
}
}
代理方法的实现
#pragma mark MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result
{
// Notifies users about errors associated with the interface
switch (result) {
case MessageComposeResultCancelled:
//用户自己取消,不用提醒
break;
case MessageComposeResultSent:
//后续可能不能够成功发送,所以暂时不提醒
break;
case MessageComposeResultFailed:
NSLog(@"短信发送失败");
break;
default:
NSLog(@"短信没有发送");
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}