#import <MessageUI/MessageUI.h>

@interface ViewController ()< MFMessageComposeViewControllerDelegate >

- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
    if ([MFMessageComposeViewController canSendText]) {
        
        MFMessageComposeViewController *mc =[[MFMessageComposeViewController alloc]init];
        mc.messageComposeDelegate=self;
        mc.body=@"你好";
        mc.recipients=[NSArray arrayWithObjects:@"10086", nil];
        [self presentViewController:mc animated:YES completion:nil];
        
    }else{
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"error" message:@"the current can not send SMS"
                                                     delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
}


- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    
    switch (result) {
            
        case MessageComposeResultCancelled:
            NSLog(@"cancell");
            break;
        case MessageComposeResultFailed:
            NSLog(@"failed");
            break;
        case MessageComposeResultSent:
            NSLog(@"sent");
            break;
        default:
            break;
    }
}

本站以现代、古代情诗为主,情诗网创办于2013年,以原创爱情诗歌、经典情诗、现代情诗、古代情诗、英文情诗、情诗绝句为主并收集古诗、古诗词、诗歌大全、诗词名句的文学门户。方便您下次继续阅读;可以放在浏览器的收藏夹中(快捷键Ctrl+D);或者看到喜欢或者有趣的诗词可以通过分享按钮给你的好友分享;情诗网是目前最全情诗大全网站之一。并欢迎广大诗歌爱好者阅览投稿!喜欢本站的话请大家把本站告诉给你朋友哦!地址是 www.qingshiwang.com !