此设备未启用短信

Joe*_*Joe 0 iphone sms

我遵循了这个教程:http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ 我得到了警告'此设备上未启用短信".

我在我的.h文件中导入了MessageUI框架"MessageUI/MessageUI.h"和MFMessageComposeViewControllerDelegate.从我在网上看到的,人们似乎能够查看MFMessageComposeViewController.

//.h file
#import <UIKit/UIKit.h>
#import "sqlite3.h"
#import <MessageUI/MessageUI.h>
...

@interface DateDetailsViewController : UIViewController <UIActionSheetDelegate, MFMessageComposeViewControllerDelegate, UINavigationControllerDelegate>
...

//.m file
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
    if([MFMessageComposeViewController canSendText])
    {
        controller.body = @"testing";
        controller.recipients = [NSArray arrayWithObjects:@"12345678", @"87654321", nil];
        controller.messageComposeDelegate = self;
        [self presentModalViewController:controller animated:YES];
    }
...
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    switch (result) {
        case MessageComposeResultCancelled:
        NSLog(@"Cancelled");
        break;
    case MessageComposeResultFailed:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Unknown Error"
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
        break;
    case MessageComposeResultSent:

        break;
    default:
        break;
}

[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

有什么我想念的吗?提前致谢.

idz*_*idz 5

MessageUI无法从模拟器发送SMS.您的应用程序需要在带有SMS服务的iPhone上运行.