问题描述
以下情况:我想发送应用短信。这是我创建MFMessageComposeViewController的代码:
following situation: I want to send in app SMS. This is my code creating the MFMessageComposeViewController:
-(void) showMessageComposerWithText:(NSString*)messageText telNumber:(NSString*)telNumber composeDelegate:(id)delegate
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = messageText;
controller.recipients = [NSArray arrayWithObject:telNumber];
controller.messageComposeDelegate = delegate;
[delegate presentModalViewController:controller animated:YES];
}
}
所以我认为这是直截了当的。在Simulator中测试时,我得到以下异常:应用程序试图在目标< MFMessageComposeViewController:0x8a4e090>
上推送nil视图控制器。我也想知道为什么 [MFMessageComposeViewController canSendText]
在模拟器中运行应用程序时返回 YES
。
So I think this is straight forward. When testing in Simulator I get following exception: Application tried to push a nil view controller on target <MFMessageComposeViewController: 0x8a4e090>
. I'm also wondering myself why [MFMessageComposeViewController canSendText]
returns YES
when running the app in the simulator.
在设备上运行时,一切正常。
When running on the device, everything is working correctly.
我在docs / web中找不到任何内容这个奇怪的行为。
I couldn't find anything in the docs/web concerning this strange behavior.
我在OS 10.7.3上运行Xcode 4.3,部署目标是iOS 5.0。
I'm running Xcode 4.3 on OS 10.7.3, Deployment Target is iOS 5.0.
提前致谢,
tubtub
Thanks in advance,tubtub
推荐答案
在OS X Lion上安装Messages beta时会出现此问题。
This problem occurs when you install Messages beta on OS X Lion.
编辑:当配置并启用iMessage帐户时,它也会出现在Mountain Lion上。如果该帐户被禁用,它可以正常工作(canSendText返回NO)。
It also occurs on Mountain Lion when there is an iMessage account configured and enabled. If the account is disabled, it works correctly (canSendText returns NO).
提示:如果您使用 controller.modalTransitionStyle = UIModalTransitionStylePartialCurl
,你可以点击左上角的卷曲页面返回模拟器。
Tip: If you use controller.modalTransitionStyle = UIModalTransitionStylePartialCurl
, you can go back in Simulator by clicking on the curled "page" in the upper left corner.
这篇关于模拟器上的MFMessageComposeViewController - canSendText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!