HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 如何在Xcode中的应用程序内发送电子邮件?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_772_2@
我是 xcode的新手,我想知道如何在应用程序中发送电子邮件!我的代码如下,但我不断收到错误“没有可见@interface for’jakem’声明选择器’presentViewControllerAnimated:’”.我的代码完全错了吗?或者我只是忘记声明选择器,我如何声明选择器?我已经在互联网上研究了至少一个小时,但没有任何工作.有人请帮帮我!

-(IBACtion)sendEmail{

    MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
    [composer setMailComposeDelegate:self];
    if ([MFMailComposeViewController canSendMail]) {
    [composer setToRecipients:[NSArray          arrayWithObjects:@"FrankMurphy.CEO@RomansXIII.com",nil]];
    [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:composer animated:YES];

    }

    }

    -(void)mailComposeController:(MFMailComposeViewController *)controller   didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    if(error) {
    UIAlertView *alert = [[UIAlertView alloc] initWithtitle:@"error" message:[NSString    StringWithFormat:@"error %@",[error description]] delegate:nil cancelButtontitle:@"dismiss" otherButtontitles:nil,nil];
    [alert show];
    [self dismissviewControllerAnimated:YES];
    }
    else {
    [self dismissviewControllerAnimated:YES];
    }
    }
@H_772_2@

@L_607_6@

在.h头文件….

#import <UIKit/UIKit.h>


#import <messageUI/messageUI.h>



@interface SimpleEmailViewController : UIViewController <MFMailComposeViewControllerDelegate> // Add the delegate
- (IBACtion)showEmail:(id)sender;



@end

在.m实现文件中…..

- (IBACtion)showEmail:(id)sender {
// Email Subject
NSString *emailtitle = @"Test Email";
// Email Content
NSString *messageBody = @"iOS progrAMMing is so fun!";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"info@finetechnosoft.in"];

MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailtitle];
[mc setmessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];

// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];
}




- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{



switch (result)
{
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail sent");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail sent failure: %@",[error localizedDescription]);
        break;
    default:
        break;
}


// Close the Mail Interface
[self dismissviewControllerAnimated:YES completion:NULL];
}
@H_772_2@ @H_772_2@
@H_772_2@
@H_772_2@

大佬总结

以上是大佬教程为你收集整理的ios – 如何在Xcode中的应用程序内发送电子邮件?全部内容,希望文章能够帮你解决ios – 如何在Xcode中的应用程序内发送电子邮件?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。