iPhone - 无论如何在你自己的应用程序内部获取iPhone的电子邮件应用程序? [英] iPhone - Anyway to get iPhone's Email App Inside Your Own App?

查看:129
本文介绍了iPhone - 无论如何在你自己的应用程序内部获取iPhone的电子邮件应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人有人将iPhone的电子邮件程序嵌入自己的应用程序?



让我尝试简化。点击Tap Revenge可以让您挑战朋友。当你选择这样做时,他们打开标准的iPhone电子邮件程序(如果他们模仿它,它看起来很好),在具有预填充数据的应用程序中。所有你需要做的是从联系人中选择一个朋友,然后按发送。你不会离开Tap Tap Revenge App。



任何想法如何完成?

解决方案

您需要将 MessageUI.framework 包含到您的项目中,您的头文件中需要设置委托:

  #import< MessageUI / MessageUI.h> 
@interface RootViewController:UIViewController< MFMailComposeViewControllerDelegate> {
MFMailComposeViewController * email;
}

@property(nonatomic,retain)MFMailComposeViewController * email;

一旦你这样做,你需要包含一些你的实现文件中的委托方法(你应该检查结果,但是我试图保留尽可能少的代码):

  @synthesize email; $ f $($)$($)$($)$($)$($)$($)$ 
}

无论您想要使用它,您需要初始化并设置为这个:

  email = [[MFMailComposeViewController alloc] init]; 
email.mailComposeDelegate = self;

//主题
[email setSubject:@Testing];

//可选附件
NSData * artwork = UIImagePNGRepresentation([UIImage imageNamed:@albumart.png]);
[email addAttachmentData:artwork mimeType:@image / pngfileName:@albumart.png];

// Body
[email setMessageBody:@This is the body];

//呈现
[self presentModalViewController:email animated:YES];


Has anyone every embeded the iPhone's Email program inside your own App?

Let me try and simplify that. Tap Tap Revenge allows you to "Challenge A Friend". When you choose to do so they open the standard iPhone email program (if they mimicked it, it looks damn good), within the application with pre-populated data. All you have to do is select a friend from your contacts and press send. You never leave the Tap Tap Revenge App.

Any ideas how this is done?

解决方案

You need to include the MessageUI.framework into your project, and inside your header file you need to set the delegate:

#import <MessageUI/MessageUI.h>
@interface RootViewController : UIViewController <MFMailComposeViewControllerDelegate> {
    MFMailComposeViewController *email;
}

@property (nonatomic, retain) MFMailComposeViewController *email;

Once you do that, you have a few delegate methods inside your implementation file you need to include (You should check to see the result, but I am trying to keep as little code as needed):

@synthesize email;

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [email dismissModalViewControllerAnimated:YES];
} 

Wherever you want to use this, you need to initialize and set it up like this:

email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;

// Subject
[email setSubject:@"Testing"];

// Optional Attachments
NSData *artwork = UIImagePNGRepresentation([UIImage imageNamed:@"albumart.png"]);
[email addAttachmentData:artwork mimeType:@"image/png" fileName:@"albumart.png"];

// Body
[email setMessageBody:@"This is the body"];

// Present it
[self presentModalViewController:email animated:YES];

这篇关于iPhone - 无论如何在你自己的应用程序内部获取iPhone的电子邮件应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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