标签: mfmailcomposeviewcontroller

MFMessageComposeViewController + SwiftUI 错误行为

我使用 ViewControllerRepresentable 来呈现 MFMessageComposeViewController,以便用户可以从我的应用程序发送文本。

然而,每次呈现视图时,它都非常有问题 - 元素随机消失,滚动关闭,并且屏幕闪烁。在 iOS 14.2 和 14.3 上测试。

这是代码:

import SwiftUI
import MessageUI

struct MessageView: UIViewControllerRepresentable {
    var recipient: String
    
    class Coordinator: NSObject, MFMessageComposeViewControllerDelegate {
        var completion: () -> Void
        init(completion: @escaping ()->Void) {
            self.completion = completion
        }
        
        // delegate method
        func messageComposeViewController(_ controller: MFMessageComposeViewController,
                                   didFinishWith result: MessageComposeResult) {
            controller.dismiss(animated: true, completion: nil)
            completion()
        }
    }

    func makeCoordinator() -> Coordinator {
        return Coordinator() {} // not using completion handler
    }
    
    func makeUIViewController(context: Context) -> MFMessageComposeViewController { …
Run Code Online (Sandbox Code Playgroud)

mfmessagecomposeviewcontroller mfmailcomposeviewcontroller swiftui uiviewrepresentable uiviewcontrollerrepresentable

4
推荐指数
1
解决办法
1459
查看次数

MFMailComposeViewController在风景中

我的应用程序是在横向模式.当我通过Present模型视图调用MFMailComposeViewController时,它来自横向mod.I旋转设备和MFMailComposeViewController视图转到纵向模式我想要限制此旋转它应该始终只在横向模式中.是否有任何这样做的方式..

mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
5095
查看次数

从iPhone程序发送后,HTML电子邮件丢失格式

我在iPhone SDK中使用MFMailComposeViewController来调出邮件对话框以发送HTML格式的电子邮件.正在从HTML文件中读取消息正文的内容,该文件在应用程序中生成并保存在文件系统中.电子邮件在发送邮件对话框中看起来很好,所有的CSS格式都在那里.但是,在将电子邮件发送到gmail和hotmail帐户后,电子邮件将以纯文本格式显示,并且所有格式都已消失.邮件是使用Gmail帐户从我的手机发送的.

当我在控制器上设置消息体时,我将isHTML设置为YES.html文件的内容非常基本; 一个定义了CSS的样式块,以及一些包含文本的div.html文件确实包含html,headbody标签(我也尝试过没有这些标签的样式div标签).

有什么想法吗?一直试图在不停的日子里搞清楚这一点.

这是电子邮件窗口,显示发送前格式正确的电子邮件: alt text http://img515.imageshack.us/img515/7962/screenshot20091031at114.png

iphone objective-c iphone-sdk-3.0 mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
6641
查看次数

iPhone不使用MessageUI发送电子邮件

嗨,我正在寻求帮助,我是可可和iphone编程的新手

有没有办法发送电子邮件,使用设备上配置的标准帐户而无需打开撰写UI?

我想写一个应用程序给我发电子邮件提醒.

你有一个文字区域,你输入的东西,当你点击标题栏上的按钮发送它发送文本区域的内容到我的电子邮件,就是这样

我已经完成了文本区域和按钮的操作,但是当我使用MFMailComposeViewController时,它会打开一个撰写窗口...

或者可能使用撰写窗口,但隐藏某些字段,例如to,cc,bcc ......

我在互联网上找到的所有文章都已过时或关于MFMailComposeViewController ......

期待听到您的重播

谢谢...

iphone cocoa-touch messageui mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
8725
查看次数

MFMailComposeViewController不从视图中删除

我有以下代码,当调用操作表上的按钮时调用该代码.但是当我按下取消,然后删除草稿时,它只是过时而且不会消失.我在我的应用程序的其他地方使用相同的代码,并从一个tableview单元格中调用它,它可以在那里找到它.任何想法为什么它不在这里工作?

当冻结时控制台中的Therg也没有错误消息.

if([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Dr. Chrono Support"];

    NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString* versionNum = [infoDict objectForKey:@"CFBundleVersion"];
    NSString *appName = [infoDict objectForKey:@"CFBundleDisplayName"];
    NSString *text = [NSString stringWithFormat:@"%@ %@",appName,versionNum];

    // Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@"contact@drchrono.com"]; 
    //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; 
    //NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

    [picker setToRecipients:toRecipients];
    //[picker setCcRecipients:ccRecipients];  
    //[picker setBccRecipients:bccRecipients];

    // Attach an image to the email
    //NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
2223
查看次数

iOS:MFMailComposeViewController无法处理模型

遇到MFMessageComposeViewController问题.情况是这样的:

我正在创建一个模型,它将实现MFMessageComposeViewController而不是直接在ViewController中执行它.现在,当我实现presentModalViewController ::方法时,它工作正常(出现mail.app接口)但是当我单击mail.app界面中的取消/发送按钮时,它不会忽略mail.app ..

它像这样的东西:

MSGViewController的一个方法片段,它实现了发送邮件模型:

- (IBAction)openEmail:(id)sender {
    Messaging *mail = [[Messaging alloc]initWithModal:self];
    [mail emailInvitation:@"Eventz Date" eventAt:@"Eventz Location" withImage:nil];
    [self.sendingStatus setText:mail.sendingStatus];
}
Run Code Online (Sandbox Code Playgroud)

我实现消息传递的模型:

Messaging.h

#import <Foundation/Foundation.h>
#import <MessageUI/MessageUI.h>

@interface Messaging : NSObject <MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate>

@property (nonatomic, copy) NSString *sendingStatus;
@property (nonatomic, retain) id modal;

- (id)initWithModal:(id)modal;
- (void)emailInvitation:(NSString *)eventDate eventAt:(NSString *)eventLocation withImage:(UIImage *)imageAttachment;

@end
Run Code Online (Sandbox Code Playgroud)

Messaging.m

#import "Messaging.h"

@implementation Messaging

@synthesize sendingStatus = _sendingStatus;
@synthesize modal = _modal;

- (id)initWithModal:(id)modal{
    self = [super init];
    self.modal = modal;
    return self;
} …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
3386
查看次数

如何通过iphone中的电子邮件发送.caf文件?

我想通过iphone中的电子邮件发送扩展名为.caf的音频文件.任何人都可以帮我这样做吗?我写过,mimeType:@"audio/caf"但我认为不支持.请帮我做这个小任务.

iphone objective-c mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
1450
查看次数

模态视图控制器不在窗口层次结构中

我试图做的应用程序有一个tabbar控制器.

当应用程序启动时,我将获得AppDelegate中的用户位置,当我获得准确性时,我需要AppDelegate将NSNotification发送到我的应用程序的起始页面(标签栏控制器的索引0).

收到通知后,此视图会尝试发送包含用户坐标和其他数据的电子邮件,但只要出现MFMailComposeViewController,我就会收到以下错误:

Warning: Attempt to present <MFMailComposeViewController: 0x98a0270> on <UITabBarController: 0x988c630> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

谢谢.

编辑:添加一些代码......

这是我在AppDelegate.m中得到的:

- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSUserDefaults *phoneNumbers = [NSUserDefaults standardUserDefaults];
NSDate *eventDate = newLocation.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 10.0) {
    [self locationUpdate:newLocation];
    smsLoc = newLocation;
    if ([[phoneNumbers objectForKey:@"sendSMS"] isEqualToString:@"yes"]) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"sendSMS" object:nil];
    } else if ([[phoneNumbers objectForKey:@"sendEmail"] isEqualToString:@"yes"]) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"sendEmail" object:nil];
    }

}
} …
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller ios mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
1万
查看次数

如何更改MFMailComposeViewController的标题颜色?

我有使用MessageUI Framework的应用内电子邮件.MFMailComposeViewController一切正常,但我想将标题颜色从黑色更改为白色.截至目前,它看起来像这样:在此输入图像描述

我还想将条形按钮项更改为白色.我能够通过所有其他视图实现所有这些功能,但我根本不知道如何使用MFMailComposeViewController执行此操作.

iphone ios swift mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
1311
查看次数

MFMailComposeViewController,Swift 4,Xcode 9

我有MFMailComposeViewControllerDelegate函数的问题.

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
    controller.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

警告说

实例方法'mailComposeController(:didFinishWith:error :)'几乎匹配协议'MFMailComposeViewControllerDelegate'的可选要求'mailComposeController(:didFinishWith:error :)'

将'mailComposeController(_:didFinishWith:error :)'私有化以使此警告无声

我需要将用户返回到App并在单击取消后关闭MFMailComposeViewController并且不会触发此功能.

是的,我添加了代表 composeVC.mailComposeDelegate = self

如果有人有类似的问题,我将不胜感激.谢谢

编辑

只有当我将语言设置为Swift 4时才会发生这种情况.我只是回过头几次提交,并且它与Swift 3.2完全正常工作

基本上,这是代码:

class TechSupportVC: UIViewController, MFMailComposeViewControllerDelegate {
    let composeVC = MFMailComposeViewController()

override func viewDidLoad() {
    super.viewDidLoad()

    composeVC.mailComposeDelegate = self
    composeVC.setToRecipients(["desiredEmail@gmail.com"])
    composeVC.setSubject("My message")
}

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
    controller.dismiss(animated: true, completion: nil)
}

@IBAction func sendPressed(_ sender: Any) {
    guard …
Run Code Online (Sandbox Code Playgroud)

xcode ios swift mfmailcomposeviewcontroller

3
推荐指数
1
解决办法
5697
查看次数