2009-09-03 58 views
2

有没有人在您的应用程序中嵌入iPhone的电子邮件程序?iPhone - 无论如何获得iPhone的电子邮件应用程序在你自己的应用程序?

让我试着简化它。 Tap Tap Revenge可让您“挑战朋友”。当你选择这样做时,他们打开标准的iPhone电子邮件程序(如果他们模仿它,它看起来非常好),在应用程序与预填充的数据。您只需从联系人中选择一位朋友,然后按发送即可。你永远不会离开Tap Tap Revenge App。

任何想法如何完成?

回答

5

您需要将MessageUI.framework包括到你的项目,你的头文件里面你需要设置代理:

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

@property (nonatomic, retain) MFMailComposeViewController *email; 

一旦你这样做,你有你需要你的执行文件中的一些委托方法包括(你应该检查的结果,但我想保持尽可能少的代码需要):

@synthesize email; 

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

不管你想用这个,你需要初始化和设置它是这样的:

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]; 
+0

谢谢,这将指向我正确的方向,让我开始!非常感谢。 – bbullis21 2009-09-04 00:07:36

0

有两个答案。对于应该支持iPhone OS 3.0之前的应用程序,唯一的方法是构建自定义消息编辑器。或者你可能想看看编写Facebook iPhone应用程序的Joe Hewitt构建的组件。

http://github.com/joehewitt/three20/blob/master/src/Three20/TTMessageController.h

随着iPhone SDK 3.0,如果你使用MessageUI.framework盒子如上所述能够使用邮件消息编写UI直出。

+0

感谢您的链接。 – bbullis21 2009-09-04 00:11:42

+0

链接不工作! – MaKo 2011-02-03 01:25:46

3

继加勒特贝尔的反响很大,你应该得到警告:

'MFMailComposeViewController' 可不回应 '-setMessageBody:'

添加isHTML:所以整条生产线倒像是:

[mail setMessageBody:@“This is the body”isHTML:NO];

0

messagecomposer是要走的路!邮件和短信内的应用程序,从iOS 3.1运行。需要sdk 4

相关问题