在 iPhone 模拟器中很难通过 MFMessageComposeViewController 获得 SMS 功能
我是 iPhone 开发新手。
这是我的问题。 我想在将 iPhone 模拟器部署到手机之前对其进行“设备短信功能”检查。这是我在 .m 文件中编写的代码。 这是触发我的短信按钮时调用的函数。
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil)
{
NSLog (@" \ntxting\n");
// We must always check whether the current device is configured for sending messages
if ([messageClass canSendText] == TRUE)
{
NSLog (@"canSendText is not passingg"); //Not entering this loop
[self displayTextSheet];
}
问题是if循环没有进入。 我想知道 Messageview 控制器是否根本不会在模拟器中弹出,并且仅适用于手机。
请指教。
更新:我在 messageClass if 循环中添加了一个 NSLog 并打印出来。 所以 messageClass 不是“nil”
I am new to iPhone developement.
Here is my question.
I would like to do a 'device texting capability' check on my iPhone simulator before I deploy it to my phone. This is the code I wrote in the .m file.
This is the function which is called when my SMS button is triggered.
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil)
{
NSLog (@" \ntxting\n");
// We must always check whether the current device is configured for sending messages
if ([messageClass canSendText] == TRUE)
{
NSLog (@"canSendText is not passingg"); //Not entering this loop
[self displayTextSheet];
}
The problem is that the if-loop does not enter.
I was wondering if the Messageview controller does not pop up in the simulator at all and only for the phone.
Please advice.
Update: I have added a NSLog in the messageClass if loop and that gets printed.
so messageClass is not 'nil'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
模拟器无法发送短信,因此在运行时
[messageClass canSendText]
返回 NO 并且您的 if 子句不会执行。The simulator cannot send SMSs, thus
[messageClass canSendText]
returns NO when run there and your if clause is not executed.