我想提前道歉,因爲我對編程相當陌生,所以如果我不具體,我可以是我很抱歉,但我會盡我所能解釋我的問題盡我所能,無論如何,我是創造需要有發送電子郵件的能力,我還到處看一個應用程序,想盡示例代碼中我能找到並沒有什麼似乎我每次使用代碼的時間來工作,我得到以下錯誤:MFmailComposer錯誤
2013-02-03 20:23:39.372 Tones[16409:c07] Warning: Attempt to present on
其視圖不在窗口層次結構中!
這是我目前正在使用的viewcontroller.h文件中的代碼:
UIViewController <MFMailComposeViewControllerDelegate>
- (IBAction)Mail:(id)sender;
,這是我viewcontroller.m文件:
- (IBAction)Mail:(id)sender {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Subject"];
NSArray *recipient = [NSArray arrayWithObjects:@"[email protected]", nil];
[mail setToRecipients:recipient];
NSString *body = @"body!";
[mail setMessageBody:body isHTML:NO];
[self presentModalViewController:mail animated:YES];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}
我也得到一個消息說,自我presentModalViewController
和自我dismissModalViewController
已被棄用在IOS 6,這是否意味着我不能使用它或我做錯了什麼?
所以對我在做什麼錯的郵件撰寫任何幫助,將不勝感激,並再次對不起,如果我事先並沒有足夠具體的感謝
使用此[自presentViewController:郵件!動畫:YES完成:無];而在使用此[self dismissViewControllerAnimated:YES completion:nil]; –