为什么 MFMailComposeViewController 的“取消”或“发送”按钮不起作用?

发布于 2024-08-26 18:30:16 字数 98 浏览 12 评论 0原文

我有一个问题...

我创建了一个 MFMailComposeViewController 并且它出现了。

但是,“发送”按钮和“取消”按钮都不起作用。

I have a problem...

I create a MFMailComposeViewController and it shows up.

However, neither the Send nor the Cancel button work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮色兮凉城 2024-09-02 18:30:16

您必须在您的应用程序中添加此代码,

   - (void)mailComposeController:(MFMailComposeViewController*)controller     didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
[self dismissModalViewControllerAnimated:YES];
}

尝试一下这个代码,它可以正常使用发送和取消按钮。

You have to put on this code in ur application,

   - (void)mailComposeController:(MFMailComposeViewController*)controller     didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
[self dismissModalViewControllerAnimated:YES];
}

Try this one and it works send and cancel buttons properly.

埋葬我深情 2024-09-02 18:30:16
MFMailComposeViewController *controller=[[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate=self;

[controller setSubject:@"Important Data"];

对于 html 文件邮件

NSString *path=[[NSBundle mainBundle]pathForResource:@"table" ofType:@"html"];
NSFileHandle *readHandle=[NSFileHandle fileHandleForReadingAtPath:path];
htmlString = [[NSString alloc] initWithData: [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];

NSString *emailBody=[NSString stringWithFormat:@"Product Name         %@ \n Company Name       %@  \n Last Updated Date   %@ \n desired data \n %@  ",lblProductName.text,lblCompanyName.text,lblUpdateDate.text,htmlString];

[controller setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:controller animated:YES];

[controller release];
MFMailComposeViewController *controller=[[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate=self;

[controller setSubject:@"Important Data"];

for html file mail

NSString *path=[[NSBundle mainBundle]pathForResource:@"table" ofType:@"html"];
NSFileHandle *readHandle=[NSFileHandle fileHandleForReadingAtPath:path];
htmlString = [[NSString alloc] initWithData: [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];

NSString *emailBody=[NSString stringWithFormat:@"Product Name         %@ \n Company Name       %@  \n Last Updated Date   %@ \n desired data \n %@  ",lblProductName.text,lblCompanyName.text,lblUpdateDate.text,htmlString];

[controller setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:controller animated:YES];

[controller release];
梦归所梦 2024-09-02 18:30:16

今天我发现Swift 3.0为这个问题带来了一个新的函数签名。在此之前,mailComposeController 从未被调用过,并且邮件(尽管确实发送了)只是停留在那里。当我改为下面时,它起作用了。

  public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith: MFMailComposeResult, error: Error?) {

    self.dismiss(animated:true, completion: nil)


}

Today I found Swift 3.0 brings a new function signature to this question. Before this, mailComposeController was never even called, and the mail (although it did send) just stuck there. When I changed to below, it worked.

  public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith: MFMailComposeResult, error: Error?) {

    self.dismiss(animated:true, completion: nil)


}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文