我是iphone开发新手,我想在我的应用程序中创建短信应用程序。我使用“messageUI.framework”创建了邮件应用程序。是否有创建短信应用程序的任何框架。不知道它,所以告诉我接近这个任务的方式。请指导我完成我的任务。请帮助我。谢谢。如何在iPhone中创建短信应用程序
2
A
回答
2
遗憾之一,没有内置的视图控制器像MFMailComposeViewController电子邮件发送短信。
从iOS 4.0开始,您可以使用MFMessageComposeViewController,它是仅限电子邮件的MFMailComposeViewController的对应物。这可让您布置并发送短信。
此外,您可以使用SMS URL方案,如this question中所述。但是,看来你是这样的cannot prepopulate the body of an SMS message。
1
发送消息比较简单 - 您通常可以将电子邮件发送至特殊格式的数字,例如[email protected](仅用于举例,不确定真实格式),然后发送至设备。本地不会有一种简单的方式在您的应用中接收短信。
你可以,但是,请尝试使用的许多free sms apis如ZeepMobile
2
您可以使用MFMessageComposeViewController类as documented by Apple。
为此,首先将MessageUI.framework添加到您的项目中。
//在.h文件中进行以下更改
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMessageComposeViewController.h>
@interface YourViewController: UIViewController <MFMessageComposeViewControllerDelegate>
//然后在.m文件做到以下几点。
- (void)viewDidLoad {
[super viewDidLoad];
SMSLabel = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 340.0, 260.0, 30.0)];
SMSLabel .frame = CGRectMake(30.0, 340.0, 260.0, 30.0);
SMSLabel .adjustsFontSizeToFitWidth = YES;
SMSLabel .hidden = YES;
SMSLabel .text = @"";
SMSLabel .userInteractionEnabled = NO;
SMSLabel.alpha=0.0;
[self.view addSubview:SMSLabel ];
}
-(void)ComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObject:@"1234567"];
picker.body = @"iPhone OS4";
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
SMSLabel.alpha=1.0;
switch (result)
{
case MessageComposeResultCancelled:
SMSLabel .text = @"Result: canceled";
NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
SMSLabel .text = @"Result: sent";
NSLog(@"Result: sent");
break;
case MessageComposeResultFailed:
SMSLabel .text = @"Result: failed";
NSLog(@"Result: failed");
break;
default:
SMSLabel .text = @"Result: not sent";
NSLog(@"Result: not sent");
break;
}
[self dismissModalViewControllerAnimated:YES];
}
0
MFMessageComposeViewController将通过iMessage应用程序发送消息。但如果你想通过你的iPhone的网络生涯发送短信,那么下面的代码将帮助你
NSString *phoneToCall = @"sms:";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
相关问题
- 1. iphone短信应用程序
- 2. iphone应用程序读短信
- 3. 从iPhone应用程序准备短信
- 4. 你如何创建一个短信调查应用程序?
- 5. 如何创建iPhone应用程序
- 6. 如何创建iPhone应用程序?
- 7. 在iPhone应用程序中创建.swf
- 8. 如何通过iPhone应用程序广播短信
- 9. 如何做iPhone的短信应用程序SPECIAL viewController转移?
- 10. iphone如何使像“短信”字段应用程序
- 11. 如何从Flash(AS3)发送短信iPhone应用程序
- 12. 我如何在iphone编程中创建Cover Flow应用程序
- 13. 在iPhone中开发短信应用程序?
- 14. 如何在横向iPhone应用程序中运行电子邮件/短信?
- 15. 从iPhone导入短信到iPhone应用程序
- 16. Iphone应用可以更改标准。短信应用程序?
- 17. 如何在iPhone中创建应用程序作为服务
- 18. 如何在iphone应用程序的表头中创建标签?
- 19. 如何在iPhone应用程序中创建和管理会话?
- 20. 如何在iPhone应用程序中创建轮播菜单栏
- 21. 如何在iPhone应用程序中创建MULTIPLE包?
- 22. 如何在iPhone应用程序中为flickr创建回调url?
- 23. 如何在iPhone应用程序中创建“每日消息”?
- 24. 如何在iphone应用程序中创建水平滚动
- 25. 如何创建数据库在iPhone应用程序中?
- 26. 如何在iPhone中创建闹钟应用程序?
- 27. 如何在iPhone应用程序中创建自定义UIAlertView
- 28. 如何在iPhone应用程序中创建本地通知
- 29. 如何在iPhone中创建本地歌曲应用程序?
- 30. 如何在iphone应用程序中创建对话框
对于AppStore或不? – kennytm
它不适用于AppStore。 – Pugal