我已经能够在所有其他视图(包括键盘)上方放置半透明视图,以使用以下代码对屏幕进行着色:
int count = [[[UIApplication sharedApplication]windows]count];
[[[UIApplication sharedApplication] windows] objectAtIndex:count-1]addSubview:tintView];
Run Code Online (Sandbox Code Playgroud)
现在我遇到了一个问题.我的应用程序使用MessageUI.framework来显示MFMessageComposeViewController,它允许用户发送文本消息.这是我遇到问题的地方.
当我在这种情况下执行上面的代码时(显示消息视图时),它可以正常工作.问题是,用户无法再与其下方的消息视图进行交互.我一直在我的tintView上将userinteractionenabled设置为NO,但在这种情况下它没有帮助解决问题.
但是,将隐藏的色调视图设置为YES确实允许交互.通过更改此属性可以使消息视图与之交互.显然,我希望tintView可见.
我在最顶层的UIWindow中查看了视图,发现UIRemoteView(我找不到任何信息,但似乎是在MessageUI.framework中显示的视图)是当tintView在它上面时没有接收到触摸的视图.
即使在其上显示另一个UIView,我如何允许与MFMessageComposeViewController进行交互.Userinteractionenabled在这种情况下不起作用,但将视图设置为隐藏(这不是我想要的).
我正在尝试为我的应用启用 MessageUI 中的相机和应用按钮。我在 Apple 的文档中没有找到关于如何执行此操作的任何地方。有任何想法吗?谢谢!
更新:我disableUserAttachments()在 Apple 的文档中找到了一个函数,这与我正在寻找的相反。Apple 特别表示,此功能会禁用消息视图中的相机/附件按钮。我的项目中没有此代码,它仍然处于禁用状态。我还没有找到像 enableUserAttachments 这样的东西,这是我认为我需要的。任何想法表示赞赏。

xcode messageui imessage mfmessagecomposeviewcontroller swift
我已经尝试了很多关于在你的应用程序中发送电子邮件的教程,但我见过的所有教程都没有显示如何使用它发送图像.我正在从.WriteToFile恢复图像,此图像设置为UIImageView.我该如何发送带有我照片的电子邮件?
尼尔
嗨,我正在寻求帮助,我是可可和iphone编程的新手
有没有办法发送电子邮件,使用设备上配置的标准帐户而无需打开撰写UI?
我想写一个应用程序给我发电子邮件提醒.
你有一个文字区域,你输入的东西,当你点击标题栏上的按钮发送它发送文本区域的内容到我的电子邮件,就是这样
我已经完成了文本区域和按钮的操作,但是当我使用MFMailComposeViewController时,它会打开一个撰写窗口...
或者可能使用撰写窗口,但隐藏某些字段,例如to,cc,bcc ......
我在互联网上找到的所有文章都已过时或关于MFMailComposeViewController ......
期待听到您的重播
谢谢...
我有一个唯一的问题。我无法关闭电子邮件窗口。我正在使用Xcode 8。
电子邮件在我第一次打开时可以正确关闭,但是如果我再次打开它则不会。如果我按“取消”,则不能选择“删除草稿”。如果我按“发送”,则发送电子邮件,但窗口不会关闭。
我的代码如下。在mailComposeController被称为正确的第一次,但它从来没有被称为第二次。有人对我缺少的东西有任何想法吗?
let mail = MFMailComposeViewController()
func sendEmail(body: String, subject: String) {
if MFMailComposeViewController.canSendMail() {
mail.mailComposeDelegate = self
mail.setSubject(subject)
mail.setMessageBody("\(body)", isHTML: false)
if let data = (body as NSString).data(using: String.Encoding.utf8.rawValue){
//Attach File
mail.addAttachmentData(data, mimeType: "text/plain", fileName: "data.txt")
}
present(mail, animated: true)
} else {
// show failure alert
}
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的迷你应用程序中实现发送电子邮件功能。
这是我正在使用的代码(取自https://hackingwithswift.com):
import Foundation
import SwiftUI
import MessageUI
func sendEmail() {
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setToRecipients(["you@yoursite.com"])
mail.setMessageBody("<p>You're so awesome!</p>", isHTML: true)
present(mail, animated: true)
} else {
// show failure alert
}
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true)
}
Run Code Online (Sandbox Code Playgroud)
运行我的代码时,出现以下 2 个错误:
Cannot find self in scope
Cannot find present in scope
我该如何修复它?
我通过messageUIFramework与MFMailComposeViewController合作.我有一个案例,我必须发送电子邮件给自己.如何添加"from"地址MFMailComposeViewController委托?有什么建议?
在过去的几天里,我一直在努力寻找一种从我的应用程序发送电子邮件的方法。这是我目前使用的示例代码。它认为,通过使用这种方法,我可能无法处理我的应用程序将运行的计算机的邮件帐户设置不当的情况,因此我考虑使用不同的方法。我想知道是否有任何适用于 mac os 的 MessageUI 等价物。mac os 是否有任何等效的 MessageUI。有任何想法吗?
我在将照片库中的图像附加到电子邮件时遇到了一些麻烦.
基本上,我的应用程序的一个功能允许用户拍照.当他们拍摄镜头时,我将URL参考记录到Core Data中的图像.我知道你必须通过去看ALAssetRepresentation图像.我已经在我的应用程序中运行并在用户想要查看他们已经拍摄的图像时运行.
我现在正试图允许用户将为活动拍摄的所有照片附加到电子邮件中.在执行此操作时,我遍历存储URL引用的Core Data实体,调用UIImage从中返回a的方法,ALAssetsLibrary然后使用NSData/ UIImageJPEGRepresentation和MFMailComposeViewController/ addAttachmentData方法将其附加.
问题是:当电子邮件呈现给用户时,表示图像的小蓝色方块没有附加图像.
这是代码:
- (void)sendReportReport
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Log: Report"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"someone@someco.com", nil];
[mailer setToRecipients:toRecipients];
NSError *error;
NSFetchRequest *fetchPhotos = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Photo" inManagedObjectContext:__managedObjectContext];
[fetchPhotos setEntity:entity];
NSArray *fetchedPhotos = [__managedObjectContext executeFetchRequest:fetchPhotos error:&error];
int counter;
for (NSManagedObject *managedObject in fetchedPhotos ) {
Photo …Run Code Online (Sandbox Code Playgroud) 我正在使用一个表视图,其中有一个单元格,上面写着"向我们发送反馈".它打开了电子邮件应用程序,其中包含要发送的预设信息.我可以发送电子邮件和/或取消它,但是当我第一次取消它时,留在桌面视图,再次点击单元格打开电子邮件,我无法再取消它.它只停留在电子邮件视图中.
建议?
我的代码如下:
import UIKit
import MessageUI
class FeedbackViewController: UITableViewController, MFMailComposeViewControllerDelegate {
let mailComposerVC = MFMailComposeViewController()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.section == 0 && indexPath.row == 0
{
let alertController = UIAlertController(title: "Rate …Run Code Online (Sandbox Code Playgroud) 非常感谢 Paulw11 帮助我解决了这个问题。我在这里添加了完整的代码以便于重用:
班级:
import UIKit
import MessageUI
struct Feedback {
let recipients: [String]
let subject: String
let body: String
let footer: String
}
class FeedbackManager: NSObject, MFMailComposeViewControllerDelegate {
private var feedback: Feedback
private var completion: ((Result<MFMailComposeResult,Error>)->Void)?
override init() {
fatalError("Use FeedbackManager(feedback:)")
}
init?(feedback: Feedback) {
guard MFMailComposeViewController.canSendMail() else {
return nil
}
self.feedback = feedback
}
func send(on viewController: UIViewController, completion:(@escaping(Result<MFMailComposeResult,Error>)->Void)) {
let mailVC = MFMailComposeViewController()
self.completion = completion
mailVC.mailComposeDelegate = self
mailVC.setToRecipients(feedback.recipients)
mailVC.setSubject(feedback.subject)
mailVC.setMessageBody("<p>\(feedback.body)<br><br><br><br><br>\(feedback.footer)</p>", isHTML: true)
viewController.present(mailVC, …Run Code Online (Sandbox Code Playgroud) class-hierarchy messageui ios swift mfmailcomposeviewcontroller
messageui ×11
ios ×7
swift ×6
email ×5
iphone ×2
mfmailcomposeviewcontroller ×2
xcode ×2
cocoa-touch ×1
image ×1
imessage ×1
ios5 ×1
macos ×1
mfmessagecomposeviewcontroller ×1
objective-c ×1
swift2 ×1
swiftui ×1
tableview ×1
uiview ×1
uiwindow ×1