iOS:发送短信 [英] iOS: Sending SMS
问题描述
可能的重复:
如何在 iPhone 上以编程方式发送短信?
有人知道如何在不使用默认 iPhone/iPad 应用程序的情况下在 iOS5 中发送短信吗?我的意思是在我的应用程序中,我有一个文本框和按钮.当我点击按钮时,文本框包含的任何字符串都将发送给指定的收件人.是否可以?谢谢,
Does someone have an idea how to send sms in iOS5 without using the default iPhone/iPad app? I mean in my app, I have a textbox and button. When I hit the button whatever string that the textbox contains will be sent to the specified recipient. Is it possible? thanks,,
推荐答案
这是不可能的 - 你必须使用 MFMessageComposeViewController
.
It's not possible - you have to use MFMessageComposeViewController
.
使用 MFMessageComposeViewController
在那里复制您自己的文本的示例:
Example of using MFMessageComposeViewController
copying your own text in there:
MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
viewController.body = yourTextField.text;
[self presentModalViewController:viewController animated:YES];
其中 yourTextField
是用于用户输入的 UITextField
或 UITextView
.
where yourTextField
is a UITextField
or UITextView
for user input.
请注意,您还需要设置 messageComposeDelegate
(可能设置为 self
)并符合 MFMessageComposeViewControllerDelegate
协议,以便知道何时驳回它.
Note you will also want to set the messageComposeDelegate
(probably to self
) and conform to the MFMessageComposeViewControllerDelegate
protocol, in order to know when to dismiss it.
这篇关于iOS:发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!