难以通过iPhone模拟器中的MFMessageComposeViewController获取SMS功能 [英] Difficulty obtaining capability to SMS via MFMessageComposeViewController in the iPhone simulator

查看:122
本文介绍了难以通过iPhone模拟器中的MFMessageComposeViewController获取SMS功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发的新手。

I am new to iPhone developement.

这是我的问题。
我想在我的iPhone模拟器上进行设备短信功能检查,然后再将其部署到手机上。这是我在.m文件中编写的代码。
这是触发我的短信按钮时调用的函数。

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];
  }

问题是if-loop没有进入。
我想知道Messageview控制器是否完全不会出现在模拟器中,只能用于手机。

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.

请建议。

更新:我在messageClass中添加了一个NSLog if循环并打印出来。
所以messageClass不是'nil'

Update: I have added a NSLog in the messageClass if loop and that gets printed. so messageClass is not 'nil'

推荐答案

模拟器无法发送短信,因此 [ messageClass canSendText] 在那里运行时返回NO,并且你的if子句没有被执行。

The simulator cannot send SMSs, thus [messageClass canSendText] returns NO when run there and your if clause is not executed.

这篇关于难以通过iPhone模拟器中的MFMessageComposeViewController获取SMS功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆