0
我想向我的应用程序中添加一个“告诉朋友”选项,该选项允许用户选择多个联系人向其发送电子邮件。联系人需要过滤给只有电子邮件地址的人。“告诉朋友”示例允许选择多个联系人
是否有人知道我可以重复使用的这样的示例。
我想向我的应用程序中添加一个“告诉朋友”选项,该选项允许用户选择多个联系人向其发送电子邮件。联系人需要过滤给只有电子邮件地址的人。“告诉朋友”示例允许选择多个联系人
是否有人知道我可以重复使用的这样的示例。
我最近搜索同样的问题,我发现iTellAfriend。这个对我有用。
从github/iTellafriend下载此源码。打开zip文件并在src文件中将iTellAFriend.h和iTellAFriend.m拖到您的项目中。检查“复制项目到目的地组文件夹(如果需要)”和“创建组文件夹的任何添加的文件夹”
在你appdelegate.m添加#import "iTellAFriend.h"
添加下列内容appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//[iTellAFriend sharedInstance].appStoreID = yourAppId;
[iTellAFriend sharedInstance].appStoreID = 408981381; //example
return YES;
}
添加#import "iTellAFriend.h"
您ViewController.m
,并在任何地方你ViewController.m
调用下面的方法(最好是在一个按钮)
if ([[iTellAFriend sharedInstance] canTellAFriend]) {
UINavigationController* tellAFriendController = [[iTellAFriend sharedInstance] tellAFriendController];
[self presentModalViewController:tellAFriendController animated:YES];
}
在iTellAFriend.m修改以下
- (UINavigationController *)tellAFriendController
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:self.messageTitle];
[picker setMessageBody:[self messageBody] isHTML:YES];
return picker;
}
到
- (UINavigationController *)tellAFriendController
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil];
[picker setToRecipients:toRecipients];
[picker setSubject:self.messageTitle];
[picker setMessageBody:[self messageBody] isHTML:YES];
return picker;
}
当您点击按钮下面的场景将出现它不会发送电子邮件上的模拟器,但是,设备