0
我試圖顯示電子郵件表單appdelegate。未找到實例方法(電子郵件表格)
AppDelegate.h
@interface AppDelegate : UIResponder <MFMailComposeViewControllerDelegate, UIApplicationDelegate>
-(void)email;
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
...
-(void)email {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Ear Dictation issue"];
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[mail setToRecipients:toRecipients];
NSString *emailBody = @"";
[mail setMessageBody:emailBody isHTML:NO];
mail.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentViewController:mail animated:YES completion:nil];//this line
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!"
message:@"E-mail is not supported on your device"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
switch (result) {
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
NSLog(@"mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"mail failed");
break;
}
[self dismissViewControllerAnimated:YES //this line
completion:nil];
}
...
而且我得到的標線這樣的錯誤。
實例方法 '-presentViewController:動畫:完成:' 未找到(返回類型默認爲 '編號')
和
實例方法 '-dismissViewControllerAnimated:完成:' 未找到(返回類型默認爲'id')
有人知道如何解決這個問題嗎?
這應該工作。無論如何,有沒有什麼辦法可以顯示它當前顯示的視圖控制器,因爲我使用標籤欄控制器? – TomasJ
'-presentViewController:animated:completion:'錯誤的解決方案可以,但第二個並沒有改變任何東西。 – TomasJ
你的意思是「解僱......」不工作?這應該。當你將'self'改爲'controller'時,你會得到什麼問題? – rmaddy