Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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
在iPhone应用程序中嵌入邮件撰写_Iphone_Email_Embed - Fatal编程技术网

在iPhone应用程序中嵌入邮件撰写

在iPhone应用程序中嵌入邮件撰写,iphone,email,embed,Iphone,Email,Embed,我想让我的应用程序发送邮件。我可以使用mailto:URL方案,但它会在启动iPhone邮件时终止我的应用程序。《独立报》(英国报纸)的新闻阅读器似乎在应用程序中显示了一个邮件撰写视图。当您发送或取消时,应用程序会立即重新出现 有人知道怎么做吗 谢谢,您需要使用3.0消息UI框架 您需要使用3.0消息UI框架 #导入 #import <MessageUI/MessageUI.h> @interface ViewReminderViewController_iPhone : UIVi

我想让我的应用程序发送邮件。我可以使用mailto:URL方案,但它会在启动iPhone邮件时终止我的应用程序。《独立报》(英国报纸)的新闻阅读器似乎在应用程序中显示了一个邮件撰写视图。当您发送或取消时,应用程序会立即重新出现

有人知道怎么做吗


谢谢,

您需要使用3.0消息UI框架

您需要使用3.0消息UI框架

#导入
#import <MessageUI/MessageUI.h>

@interface ViewReminderViewController_iPhone : UIViewController
            <MFMailComposeViewControllerDelegate>
{
UiButton *mailButton;
}
- (IBAction)EmailButton:(id)sender;
@end

@implementation ViewController
- (IBAction)EmailButton:(id)sender
{

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:@"Your EMail Subject"];

    //SET UP THE RECIPIENTS (or leave not set)
    //NSArray *toRecipients = [NSArray arrayWithObjects:@"first@example.com", nil];
    //[picker setToRecipients:toRecipients];

    //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
    //[picker setCcRecipients:ccRecipients];

    //NSArray *bccRecipients = [NSArray arrayWithObjects:@"four@example.com", nil];
    //[picker setBccRecipients:bccRecipients];

    //ATTACH FILE

    NSString *path;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"MediaFiles"];
    path = [path stringByAppendingPathComponent:MyFileName];

    NSLog(@"Attaching file: %@", path);

    if ([[NSFileManager defaultManager] fileExistsAtPath:path])     //Does file exist?
    {
            NSLog(@"File exists to attach");

            NSData *myData = [NSData dataWithContentsOfFile:path];

            [picker addAttachmentData:myData mimeType:@"application/octet-stream"
                             fileName:@"DesredFileName.mov"];

    }

    //CREATE EMAIL BODY TEXT
    NSString *emailBody = @"Your Email Body";
    [picker setMessageBody:emailBody isHTML:NO];

    //PRESENT THE MAIL COMPOSITION INTERFACE
    [self presentModalViewController:picker animated:YES];
    [picker release];

}
Delegate To Clear Compose Email View Controller


- (void)mailComposeController:(MFMailComposeViewController *)controller
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError *)error
{

    [self dismissModalViewControllerAnimated:YES];      //Clear the compose email view controller
}
@界面视图提醒服务控制器\u iPhone:UIViewController { UiButton*邮件按钮; } -(iAction)EmailButton:(id)发件人; @结束 @实现视图控制器 -(iAction)EmailButton:(id)发件人 { MFMailComposeViewController*选择器=[[MFMailComposeViewController alloc]init]; picker.mailComposeDelegate=self; [picker setSubject:@“您的电子邮件主题”]; //设置收件人(或保留未设置) //NSArray*toRecipients=[NSArray arrayWithObjects:@”first@example.com“,无]; //[picker setToRecipients:toRecipients]; //NSArray*ccRecipients=[NSArray arrayWithObjects:@”second@example.com", @"third@example.com“,无]; //[选择器设置ccRecipients:ccRecipients]; //NSArray*BCCreciients=[NSArray arrayWithObjects:@”four@example.com“,无]; //[选取者/接收者:b委托人]; //附加文件 NSString*路径; NSArray*Path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,是); path=[[paths objectAtIndex:0]stringByAppendingPathComponent:@“MediaFiles”]; path=[path stringByAppendingPathComponent:MyFileName]; NSLog(@“附加文件:%@”,路径); 如果([[NSFileManager defaultManager]fileExistsAtPath:path])//文件是否存在? { NSLog(@“要附加的文件已存在”); NSData*myData=[NSData dataWithContentsOfFile:path]; [picker addAttachmentData:myData mimeType:@“应用程序/八位字节流” 文件名:@“DesredFileName.mov”]; } //创建电子邮件正文文本 NSString*emailBody=@“您的电子邮件正文”; [picker setMessageBody:emailBody isHTML:NO]; //显示邮件合成界面 [自我呈现ModalviewController:picker动画:是]; [选择器释放]; } 委托以清除撰写电子邮件视图控制器 -(无效)mailComposeController:(MFMailComposeViewController*)控制器 didFinishWithResult:(MFMailComposer结果)结果 错误:(n错误*)错误 { [自我解除ModalViewController激活:是];//清除撰写电子邮件视图控制器 }
#导入
@界面视图提醒服务控制器\u iPhone:UIViewController
{
UiButton*邮件按钮;
}
-(iAction)EmailButton:(id)发件人;
@结束
@实现视图控制器
-(iAction)EmailButton:(id)发件人
{
MFMailComposeViewController*选择器=[[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate=self;
[picker setSubject:@“您的电子邮件主题”];
//设置收件人(或保留未设置)
//NSArray*toRecipients=[NSArray arrayWithObjects:@”first@example.com“,无];
//[picker setToRecipients:toRecipients];
//NSArray*ccRecipients=[NSArray arrayWithObjects:@”second@example.com", @"third@example.com“,无];
//[选择器设置ccRecipients:ccRecipients];
//NSArray*BCCreciients=[NSArray arrayWithObjects:@”four@example.com“,无];
//[选取者/接收者:b委托人];
//附加文件
NSString*路径;
NSArray*Path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,是);
path=[[paths objectAtIndex:0]stringByAppendingPathComponent:@“MediaFiles”];
path=[path stringByAppendingPathComponent:MyFileName];
NSLog(@“附加文件:%@”,路径);
如果([[NSFileManager defaultManager]fileExistsAtPath:path])//文件是否存在?
{
NSLog(@“要附加的文件已存在”);
NSData*myData=[NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@“应用程序/八位字节流”
文件名:@“DesredFileName.mov”];
}
//创建电子邮件正文文本
NSString*emailBody=@“您的电子邮件正文”;
[picker setMessageBody:emailBody isHTML:NO];
//显示邮件合成界面
[自我呈现ModalviewController:picker动画:是];
[选择器释放];
}
委托以清除撰写电子邮件视图控制器
-(无效)mailComposeController:(MFMailComposeViewController*)控制器
didFinishWithResult:(MFMailComposer结果)结果
错误:(n错误*)错误
{
[自我解除ModalViewController激活:是];//清除撰写电子邮件视图控制器
}