iOS发送短信

iPhone开发中,发送短信方法有二:

1。URL Scheme,这样不可以设置短信内容

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://10086"]];
//打电话可以这样
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]]; 

2。MFMessageComposeViewController,这样可以设置短信的内容

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
        if ([MFMessageComposeViewController canSendText])        {
            if (![self.friendLabel.text isEqualToString:@"{好友}"])
                controller.recipients = [NSArray arrayWithObjects:self.friendLabel.text, nil];
                controller.body = self.shareMessageTextView.text;
                controller.messageComposeDelegate = self;
                [self presentModalViewController:controller animated:YES];
        }
 

猜你喜欢

转载自hulefei29.iteye.com/blog/1698319