MFMailComposer - 适用于模拟器,但不适用于iPhone 2G

时间:2009-09-22 12:15:16

标签: iphone

我正在尝试将MFMailComposer添加到我的iPhone应用程序中,并且没有太多运气让它在我的iPhone 2G中启动。它总是将电子邮件应用程序启动到帐户页面并关闭我的应用程序。就像模拟器中的魅力一样。

- (无效)viewWillAppear中:(BOOL)动画 {     [super viewWillAppear:animated];

[self displayComposerSheet];

} - (无效)displayComposerSheet {

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
    // you have the MFMailComposeViewController class
    MFMailComposeViewController *picker =  [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

NSArray *mailArr = [[NSArray alloc] initWithObjects:self.sendTo,nil];       

[picker setSubject:@"Hello from iCamp America"];
[picker setToRecipients:mailArr];
NSString *emailBody = @"\n\n\email created with iCamp America\nwww.iCampAmerica.com";
[picker setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:picker animated:YES];
[picker release];
[mailArr release];
}
else
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"You cannot send an email !" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
}

}

2 个答案:

答案 0 :(得分:0)

MFMailComposeViewController仅适用于iPhone OS> 3.0。你在开发手机上运行那个版本吗?

答案 1 :(得分:0)

愚蠢的我 - 我发现我发送电子邮件的电话有冲突 - 我用同一个动作触发器调用了mailTo:URL和MFMailComposer方法......