Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
573 views
in Technique[技术] by (71.8m points)

ios5 - MFMessageComposeViewController on Simulator - canSendText?

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

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.

I couldn't find anything in the docs/web concerning this strange behavior.

I'm running Xcode 4.3 on OS 10.7.3, Deployment Target is iOS 5.0.

Thanks in advance, tubtub

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This problem occurs when you install Messages beta on OS X Lion.

Edit: 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).

Tip: If you use controller.modalTransitionStyle = UIModalTransitionStylePartialCurl, you can go back in Simulator by clicking on the curled "page" in the upper left corner.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...