“告诉朋友"允许选择多个联系人的示例 [英] "Tell Friend" example which allow selection multiple contact

查看:26
本文介绍了“告诉朋友"允许选择多个联系人的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中添加一个告诉朋友"选项,该选项允许用户选择多个联系人以向他们发送电子邮件.联系人需要过滤为仅具有电子邮件地址的联系人.

I would like to add to my application a "Tell Friend" option which allow user to select multiple contacts to send them email. Contact need to be filtered to the one who have email address only.

任何人都知道我可以重用的现成示例.

does any one know such ready example that I could reuse.

推荐答案

我最近在搜索相同的问题,但发现了iTellAfriend.这个对我有用.

I recently searching for the same problem and I found iTellAfriend. It works for me.

github/iTellafriend 下载此源代码.打开zip文件,并在src文件中将iTellAFriend.h和iTellAFriend.m拖到您的项目中.选中将项目复制到目标组文件夹(如果需要)"和为任何添加的文件夹创建组文件夹"

Download this source code from github/iTellafriend. Open zip file and inside src file drag iTellAFriend.h and iTellAFriend.m to your project. Check "Copy items into destination group folder(if needed)" and "Create group folder for any added folders"

在您的appdelegate.m中添加 #import"iTellAFriend.h"

In your appdelegate.m add #import "iTellAFriend.h"

将以下内容添加到您的appdelegate.m

Add following to your 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 中的任何位置,调用以下方法(最好在一个按钮)

Add #import "iTellAFriend.h" to your ViewController.m and anywhere in your ViewController.m call following method (preferably in a button)

if ([[iTellAFriend sharedInstance] canTellAFriend]) {
            UINavigationController* tellAFriendController = [[iTellAFriend sharedInstance] tellAFriendController];
            [self presentModalViewController:tellAFriendController animated:YES];
        }

在iTellAFriend.m中进行以下修改

In iTellAFriend.m modify following

- (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:@"xxxx@xxxx.com", @"xxxxx@xxxx.com", nil];
    [picker setToRecipients:toRecipients];

  [picker setSubject:self.messageTitle];
  [picker setMessageBody:[self messageBody] isHTML:YES];

  return picker;
}

当您单击按钮时,将显示以下场景,它将不会在模拟器上发送电子邮件,但会在设备上发送电子邮件

when you click your button following scene will appear it wont send the email on simulator but on device

这篇关于“告诉朋友"允许选择多个联系人的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆