2009-09-22 53 views
1

我想添加MFMailComposer到我的iPhone應用程序,並沒有太多的運氣得到它在我的iPhone 2G啓動。它總是將電子郵件應用程序啓動到帳戶頁面並關閉我的應用程序。像模擬器中的魅力一樣工作。MFMailComposer - 作品在模擬器,但不是在iPhone 2G

- (void)viewWillAppear:(BOOL)animated {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]; 
} 

}

回答

0

的MFMailComposeViewController僅適用於iPhone OS> 3.0可用。你在開發手機上運行該版本嗎?

+0

是 - 在模擬器中運行3.1並在我的iPhone中 – user160462 2009-09-23 14:09:05

0

愚蠢的我 - 我發現,我已經衝突的通話,發送電子郵件 - 我打電話兩者的mailto:URL和MFMailComposer方法具有相同的動作觸發.....

相關問題