xcode iOS:发送短信
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8999844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS: Sending SMS
提问by Aldee
Possible Duplicate:
How to programmatically send SMS on the iPhone?
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,,
有人知道如何在不使用默认 iPhone/iPad 应用程序的情况下在 iOS5 中发送短信吗?我的意思是在我的应用程序中,我有一个文本框和按钮。当我点击按钮时,文本框包含的任何字符串都将发送给指定的收件人。是否可以?谢谢,,
回答by mattjgalloway
It's not possible - you have to use MFMessageComposeViewController
.
这是不可能的 - 你必须使用MFMessageComposeViewController
.
Example of using MFMessageComposeViewController
copying your own text in there:
MFMessageComposeViewController
在那里使用复制您自己的文本的示例:
MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
viewController.body = yourTextField.text;
[self presentModalViewController:viewController animated:YES];
where yourTextField
is a UITextField
or UITextView
for user input.
其中yourTextField
是UITextField
或UITextView
用于用户输入。
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.
请注意,您还需要设置messageComposeDelegate
(可能为self
)并遵守MFMessageComposeViewControllerDelegate
协议,以便知道何时关闭它。