我正在使用MFMailComposeViewController在我的应用程序中发送反馈.它工作正常.但问题在于,用户可以编辑/删除"到"地址.我想把它作为一个不可编辑的.可能是,用户可以在"到"字段中添加一些邮件地址.
但是他/她不应该删除反馈地址(这里是"support@xxxx.com").
这是我的代码......
MFMailComposeViewController *composeWindow = [[MFMailComposeViewController alloc] init];
composeWindow.mailComposeDelegate = self;
NSString *str = @"Subject of the feedback";
[composeWindow setSubject:[str stringByAppendingString:[[UIDevice currentDevice]systemVersion]]];
NSArray *toRecipients = [NSArray arrayWithObject: @"support@xxxx.com"];
[composeWindow setToRecipients:toRecipients];
[self presentModalViewController:composeWindow animated:YES];
[composeWindow release];
Run Code Online (Sandbox Code Playgroud)
提前致谢
Rajkanth
当用户使用MFMailComposeViewController从iPhone发送成功邮件时,我需要显示警告消息.
我尝试使用didFinishWithResult委托,但它要求发送和取消然后我们如何确定我们成功发送消息?
由于某种原因,发送和取消按钮没有出现,我甚至在appdelegate中的应用程序开始时粘贴了以下代码,只是当应用程序启动但仍无法正常工作时.任何人都可以帮忙,谢谢
mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setToRecipients:[strToEmailAddresses componentsSeparatedByString:@","]];
[mailController setSubject:@"An Invite from MyGuide"];
[mailController setMessageBody:@"Join me and your other friends now for free." isHTML:NO];
if(mailController == nil)
NSLog(@"Nil");
else
[self presentModalViewController:mailController animated:YES];
Run Code Online (Sandbox Code Playgroud) 我在使用conMail时使用MFMailComposeViewController来提供Mail功能,但是发送邮件后或当我想取消邮件时,它将崩溃。
下面是我的代码:
(IBAction)FnForPlutoSupportEmailButtonPressed:(id)sender {
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Need help from Pluto support team"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"support@myplu.to",nil];
[mailer setToRecipients:toRecipients];
NSString *emailBody = @"";
[mailer setMessageBody:emailBody isHTML:NO];
//mailer.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:mailer animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}
} }
(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated …Run Code Online (Sandbox Code Playgroud) iphone presentmodalviewcontroller ios mfmailcomposeviewcontroller
编写应用程序的一部分,允许用户生成pdf并发送它.似乎工作正常.发送的PDF在MAC上打开正常,但在iPhone上它只是保持加载而从未打开.在Ray Wenderlich Tutorial的帮助下创建了一个pdf文档,并通过一个带有MFMailComposeViewController实例的模态视图控制器发送出来.WTF我做错了.
更新:PDF也在Ipad上正常打开.问题可能出现在创建PDF的代码中吗?另外我有点不清楚,如果我实际创建的PDF是持久的,然后在相同命名文件的每个新版本之后被替换,或者我在某种程度上欺骗编译器认为文档正在存储,所以我可以发送它尽可能少的代码.
对此的任何想法将不胜感激.
看看代码:
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"mail test"];
NSString* fileName = @"Invoice.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
NSData *myData = [NSData dataWithContentsOfFile:pdfFileName];
[picker addAttachmentData:myData mimeType:@"application/pdf" fileName:@"the PDF"];
[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)
}
pdf email-attachments ios mime-types mfmailcomposeviewcontroller
在我的应用程序中,我有一个按钮,当按下时打开一个电子邮件,填写"to"和"subject",但我在这行代码上收到此警告:
mc.mailComposeDelegate = self;
Run Code Online (Sandbox Code Playgroud)
警告说:
Assigning to 'id<MFMailComposeViewControllerDelegate>'from incompatible type 'ViewController *const_strong'
我该怎么办?请非常清楚,我对xCode不太熟练.
以下是我在邮件中发送附件的代码.这很好用.我能够发送邮件,但我并不总是收到邮件.
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
// Set the subject of email
[picker setSubject:@"My data file"];
// Add email addresses
[picker setToRecipients:[NSArray arrayWithObjects:emailId, nil]];
// Fill out the email body text
NSString *emailBody = @"Hello, \n Please find the data from the iOS app in the attachments.\n\n Thank you.\nMy Team.";
// This is not an HTML formatted email
[picker setMessageBody:emailBody isHTML:NO];
// Create NSData object from file
NSData *exportFileData = [NSData dataWithContentsOfFile:filePath];
// Attach image data …Run Code Online (Sandbox Code Playgroud) 无论我似乎尝试什么,在用户选择通过电子邮件发送链接时出现的电子邮件屏幕(它是a MFMailComposeViewController),按钮始终是默认的蓝色.
我在我的AppDelegate中有这个:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.000 green:156/255.0 blue:51/255.0 alpha:1]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName: [UIColor whiteColor] }];
Run Code Online (Sandbox Code Playgroud)
它确实为标题MFMailComposeViewController而不是按钮着色.我该如何做到这一点?
当我在其他地方把它变成白色时,它也会使我的状态栏保持黑色.
objective-c ios uiappearance ios7 mfmailcomposeviewcontroller
在同一个viewcontroller上,我们可以发送电子邮件或短信来向朋友发送信息.应用程序中的短信完全有效.但对于电子邮件,电子邮件应用程序在我的应用程序中打开,包含我要求写的所有信息但是不可能通过推送取消来解雇它,没有任何反应.我试过mc.mailComposeDelegate = self或mc.delegate = self,而MFMailComposeViewControllerDelegate也在顶部.我在互联网上看了一切,我没有找到任何解释.永远不会调用mailComposeController!你有什么主意吗 ?
class inviteAFriendViewController: UIViewController, MFMessageComposeViewControllerDelegate, MFMailComposeViewControllerDelegate {
@IBAction func emailButtonDidTouch(sender: AnyObject) {
sendEmail()
}
func sendEmail() {
let emailTitle = "text"
let messageBody = "text"
let toRecipents = [""]
let mc = MFMailComposeViewController()
//mc.mailComposeDelegate = self
mc.delegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
presentViewController(mc, animated: true, completion: nil)
}
func mailComposeController(controller2: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
switch result.rawValue {
case MFMailComposeResultCancelled.rawValue:
print("Mail cancelled")
controller2.dismissViewControllerAnimated(true, completion: nil)
case MFMailComposeResultSaved.rawValue:
print("Mail saved")
controller2.dismissViewControllerAnimated(true, completion: …Run Code Online (Sandbox Code Playgroud) 我已经在我的一些应用程序中使用了一段时间的mail composer,最近,mailComposeDelegate不再被调用。
我不确定这是否与Swift的新版本有关。
因此,我想问一下是否还有其他人遇到类似的问题。
我可以介绍邮件编辑器,但是由于代理不起作用,它永远不会被关闭。
以下是我一直在使用的代码的精确副本:
func launchFeedback() {
guard MFMailComposeViewController.canSendMail() else {
return
}
let emailTitle = "Feedback"
let messageBody = ""
let toRecipents = ["johnappleseed@icloud.com"]
mailComposer.mailComposeDelegate = self
mailComposer.setSubject(emailTitle)
mailComposer.setMessageBody(messageBody, isHTML: false)
mailComposer.setToRecipients(toRecipents)
self.show(mailComposer, sender: self)
}
func mailComposeController(controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
print(error)
controller.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud) mfmailcomposeviewcontroller ×10
ios ×5
iphone ×4
email ×2
objective-c ×2
swift ×2
delegates ×1
feedback ×1
ios7 ×1
mime-types ×1
pdf ×1
swift3 ×1
uiappearance ×1
xcode ×1