问题描述
我是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功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!