Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UIActionSheet中获取电子邮件客户端_Ios_Objective C_Iphone_Xcode_Email - Fatal编程技术网

Ios 在UIActionSheet中获取电子邮件客户端

Ios 在UIActionSheet中获取电子邮件客户端,ios,objective-c,iphone,xcode,email,Ios,Objective C,Iphone,Xcode,Email,我想让电子邮件客户端进入一个动作,当我点击一个电子邮件客户端时,电子邮件应该从那个特定的客户端发送。有人能告诉我如何实施吗? 它应该如上图所示。希望这对您有所帮助 UIActionSheet* sheet = [[[UIActionSheet alloc] init] autorelease]; sheet.title = @"Add Accounts"; sheet.delegate = self; [sheet addButtonWithTitle:@"iCloud"]; [sheet a

我想让电子邮件客户端进入一个动作,当我点击一个电子邮件客户端时,电子邮件应该从那个特定的客户端发送。有人能告诉我如何实施吗?


它应该如上图所示。

希望这对您有所帮助

UIActionSheet* sheet = [[[UIActionSheet alloc] init] autorelease];
sheet.title = @"Add Accounts";
sheet.delegate = self;
[sheet addButtonWithTitle:@"iCloud"];
[sheet addButtonWithTitle:@"Google"];
[sheet addButtonWithTitle:@"Yahoo"];
if (condition)
[sheet addButtonWithTitle:@"XYZ"];
sheet.cancelButtonIndex = [sheet addButtonWithTitle:@"Cancel"];
然后您必须为itemclick创建方法从actionsheet,您必须使用以下代码打开邮件应用程序

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init];
    emailController.mailComposeDelegate = self;

    [emailController setSubject:subject];
    [emailController setMessageBody:mailBody isHTML:YES];   
    [emailController setToRecipients:recipients];

    [self presentViewController:emailController animated:YES completion:nil];

    [emailController release];
}
// Show error if no mail account is active
else {
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"You must have a mail account in order to send an email" delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
    [alertView show];
    [alertView release];
}

注意,如果您想从应用程序本身发送电子邮件,您可以使用MFMailComposeViewController

希望这对您有所帮助

UIActionSheet* sheet = [[[UIActionSheet alloc] init] autorelease];
sheet.title = @"Add Accounts";
sheet.delegate = self;
[sheet addButtonWithTitle:@"iCloud"];
[sheet addButtonWithTitle:@"Google"];
[sheet addButtonWithTitle:@"Yahoo"];
if (condition)
[sheet addButtonWithTitle:@"XYZ"];
sheet.cancelButtonIndex = [sheet addButtonWithTitle:@"Cancel"];
然后您必须为itemclick创建方法从actionsheet,您必须使用以下代码打开邮件应用程序

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init];
    emailController.mailComposeDelegate = self;

    [emailController setSubject:subject];
    [emailController setMessageBody:mailBody isHTML:YES];   
    [emailController setToRecipients:recipients];

    [self presentViewController:emailController animated:YES completion:nil];

    [emailController release];
}
// Show error if no mail account is active
else {
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"You must have a mail account in order to send an email" delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
    [alertView show];
    [alertView release];
}


注意,如果您想从应用程序本身发送电子邮件,您可以使用MFMailComposeViewController

Apple不提供获取客户端的API。您必须自行设计操作表图标,在MFMailComposeViewController点击“发件人”字段时,您必须使用合适的电子邮件ID自动填充该字段。

苹果公司不提供API来获取客户端。您必须自行设计操作表图标,并在MFMailComposeViewController中点击“发件人”字段,您必须使用合适的电子邮件ID自动填充该字段。

您到底想要什么?在UIActionSheet中,我想显示所有电子邮件客户端,以便我可以从选定的电子邮件客户端发送电子邮件您想列出已安装的电子邮件客户端应用程序,然后单击它,打开应用程序以发送您的电子邮件?您到底想要什么?在UIActionSheet中,我想显示所有电子邮件客户端,以便我可以从选定的电子邮件客户端发送电子邮件您想列出已安装的电子邮件客户端应用程序并单击它,打开应用程序以发送电子邮件?您必须在“我的代码”中的“设置收件人”中添加要向其发送电子邮件的电子邮件id。但邮件将仅从邮件客户端(邮件应用程序)发送,但我希望从该特定客户端发送。是否有第三方类用于此?然后,您需要使用自定义URL Scheme.ex。对于Gmail应用程序,您必须使用-googlegmail://Sorry 要问,你能给我举个例子吗..我是IOS新手,你必须在我的代码中以“setToRecipients”的形式添加要向其发送电子邮件的电子邮件id。但是邮件将仅从邮件客户端(邮件应用程序)发送,但我想从该特定客户端发送。是否有第三方类用于此?然后,您需要使用自定义URL Scheme.ex。对于Gmail应用程序,您必须使用-googlegmail://Sorry 你能给我举个例子吗我对IOS不熟悉