我正在尝试MFMailComposeViewController在应用程序中显示。
if MFMailComposeViewController.canSendMail() {
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.navigationBar.tintColor = .white
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setToRecipients(["support@gmail.com"])
mailComposeViewController.setSubject("Feedback")
present(mailComposeViewController, animated: true)
} else {
print("This device is not configured to send email. Please set up an email account.")
}
Run Code Online (Sandbox Code Playgroud)
在 iOS 12 中,它显示没有问题。在模拟器和设备中。
但是当我在运行 iOS 13 的设备上运行相同的项目时,它看起来像这样。
导航栏颜色不见了。此外,发送按钮也是不可见的。
所以我添加了mailComposeViewController.navigationBar.backgroundColor = .mv_primary但它仍然没有显示在设备上。奇怪的是,背景颜色显示在模拟器中。
然而,有一个奇怪的行为。该MFMailComposeViewController立即本身驳回时,我在模拟器中运行它。
以下错误也显示在 Xcode 控制台中。
[常见] [FBSSystemService][0x5f27] 处理 com.apple.MailCompositionService 的打开请求时出错:{ userInfo = { FBSOpenApplicationRequestID = 0x5f27; } 底层错误 = ; } 2019-11-01 14:40:05.214158+0530 MailCompose[11289:262267] [Assert] 连接请求在没有恢复我们的 …
我在我的iPhone应用程序中使用了一个有色的导航栏和一个有色的全球UIToolbar.在我的信息视图中,我有一个打开MFMailComposeViewController的按钮,该视图顶部的工具栏(带有"取消"和"发送"按钮)仍为蓝色.我正在调用MFMailComposeViewController,如下所示:
-(void)displayMailSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"..."];
NSArray *toRecipients = [NSArray arrayWithObject:@"..."];
[picker setToRecipients:toRecipients];
[self presentModalViewController:picker animated:YES];
[picker release];
}
Run Code Online (Sandbox Code Playgroud)
是否可以更改该视图工具栏的颜色?如果有可能,我该怎么做?
我正在尝试更改MFMailComposerViewController中导航按钮的文本颜色,但它在iOS 6上不起作用.在iOS 6中,它与UIAppearance一起工作如下:
// Navigation button
UIBarButtonItem *barButton = [UIBarButtonItem appearance];
NSDictionary *barButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor redColor]};
NSDictionary *disabledBarButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor grayColor]};
[barButton setTitleTextAttributes:barButtonTitleTextAttributes forState:UIControlStateNormal];
[barButton setTitleTextAttributes:disabledBarButtonTitleTextAttributes forState:UIControlStateDisabled];
[barButton setBackgroundImage:[[UIImage imageNamed:@"btn_appearance"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
但这在iOS 7上不起作用,看起来总是这样:

我也尝试tintColor在navigationBar上设置属性,但这也没有效果:
navigationBar.tintColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)
无论如何在iOS 7上更改MFMailComposeViewController中的导航按钮文本颜色?
在我的应用程序中,MFMailComposeViewController工作正常,但创建MFMessageComposeViewController的新实例失败.
以下是两者的代码:
-( IBAction)sendSMS: (id)sender
{
MFMessageComposeViewController *picker = [[[MFMessageComposeViewController alloc] init] autorelease];
picker.messageComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject: cell.currentTitle ];
picker.recipients = toRecipients;
[self presentModalViewController:picker animated:YES];
}
-( IBAction)sendEmail: (id)sender
{
MFMailComposeViewController *picker = [[[MFMailComposeViewController alloc] init] autorelease];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject: email.currentTitle ];
[picker setToRecipients:toRecipients];
[self presentModalViewController:picker animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
由于电子邮件视图控制器工作正常,所以一切都正确链接似乎很明显.是否有一些我错过的配置明智?
我正在使用MFMailComposeViewController从iPhone v3.0应用程序中发送电子邮件.我以编程方式创建消息正文文本并在显示选择器之前显示它.
在我的邮件底部正文文本是字符串"从我的iPhone发送".是否有修改此文本或阻止它出现?粗略审查MFMailComposeViewController类参考和快速谷歌搜索没有任何结果.
提前致谢.
email iphone message boilerplate mfmailcomposeviewcontroller
在iOS 6上,在发送一些电子邮件消息后(通过使用MFMailComposeViewController),电子邮件屏幕打开速度非常慢 - 首次打开时没有填充任何字段(没有主题,没有正文等)几秒钟,并且最终(在发送大约8条消息之后),在电子邮件视图控制器正确显示之前,向用户显示黑屏几秒钟.
在显示每个黑屏之前,日志会吐出以下行:
[MFMailComposeRemoteViewController:....]等待来自com.apple.MailCompositionService的围栏障碍超时
此外,在iOS6上使用MFMailComposeViewController会导致MailCompositionS进程开始占用内存(它在我的iPhone上一直上升到大约260MB).我假设这是MFMailComposeViewController显示问题的原因.
在iOS 5上运行正常.此问题仅发生在iOS 6上.
有没有人找到解决这个问题的方法?
谢谢!
代码是标准的,但无论如何我都会包含它:
-(IBAction)doEmailLog:(id)sender
{
if( [self canSendMail] )
{
// create the compose message view controller
MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];
// this class will handle the cancel / send results
mailComposer.mailComposeDelegate = self;
// fill in the header and body
[mailComposer setSubject:@"My Subject"];
[mailComposer setMessageBody:@"My message body" isHTML:NO];
// attach log file
if ([[NSFileManager defaultManager] fileExistsAtPath:filename])
{
NSData *data = [NSData dataWithContentsOfFile:filename];
[mailComposer addAttachmentData:data mimeType:@"text/plain" fileName:filename];
} …Run Code Online (Sandbox Code Playgroud) 我有一个视图控制器,以模态方式打开MFMailComposeViewController.当我尝试将邮件视图控制器的委托设置为父视图控制器时,我收到此警告:
Assigning to 'id<UINavigationControllerDelegate>' from incompatible
type 'MoreViewController *__strong'
Run Code Online (Sandbox Code Playgroud)
父视图控制器在其接口声明中肯定有MFMailComposeViewControllerDelegate,并且正在实现委托方法-mailComposeController: didFinishWithResult:error:,如下所示:
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
NSLog(@"Delegate called");
}
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么父视图控制器被识别为UINavigationControllerDelegate,因为我没有实现这些方法,也没有这样声明它.我不会那么担心它,但委托方法永远不会被调用,所以我猜这个"不匹配"是问题的一部分.
如果它有帮助,这就是我在邮件视图控制器中的方式viewDidLoad:
// MAIL
self.mail = [[MFMailComposeViewController alloc] init];
self.mail.delegate = self;
Run Code Online (Sandbox Code Playgroud)
提前感谢您的任何想法.
iphone objective-c messageui ios mfmailcomposeviewcontroller
我在我的应用程序中使用MFMailComposeViewController进行应用内电子邮件,但我无法更改标题.默认情况下,它会在标题中显示主题,但我想将标题设置为其他内容.我怎样才能做到这一点?
我试过了:
controller.title = @"Feedback";
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
这是我的代码:
- (IBAction)email {
NSArray *array = [[NSArray alloc] initWithObjects:@"myemail@gmail.com", nil];
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[[controller navigationBar] setTintColor:[UIColor colorWithRed:0.36 green:0.09 blue:0.39 alpha:1.00]];
controller.mailComposeDelegate = self;
controller.title = @"Feedback";
[controller setSubject:@"Long subject"];
[controller setMessageBody:@""
isHTML:NO];
[controller setToRecipients:array];
[self presentModalViewController:controller animated:YES];
[controller release];
[array release];
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud) email iphone objective-c iphone-sdk-3.0 mfmailcomposeviewcontroller
我见过这样几个问题,如本但缺乏一个公认的答案,以及根据需要我还是继续面对的课题有实现的事情如下:我显示邮件的作曲家,但在点击取消,作曲家视图冻结.我认为这是由于保存/删除草稿操作表显示在可见框架之外.是的我已经将mailComposeDelegate设置为呈现视图控制器,并且已经阅读了几个类似的问题,其中用户没有处理(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error委托以取消取消作曲家.我也处理了这个问题,但我似乎无法弄清楚为什么动作表不会出现在我的通用应用程序的iPhone版本的屏幕的可见区域中.以模块方式将邮件编辑器呈现为NSLogged的视图控制器的视图框架是(0,0,320,480).我的应用程序是通用的,邮件编辑器在iPad上完美运行.下面是在iPhone模拟器5.1上运行的作曲家视图的截图: - 
这是显示作曲家的代码:
-(IBAction)mailButtonPressed:(id)sender {
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Subject"];
[controller setMessageBody:@"Test" isHTML:YES];
[controller setToRecipients:nil];
if(controller) {
[self presentModalViewController:controller animated:YES];
[controller release];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud) iphone cancel-button ios mfmailcomposer mfmailcomposeviewcontroller
我想从我的应用程序发送邮件.我正在用SWIFT完成我的第一步,我已经陷入困境.我想按一个按钮打开邮件.你能告诉我怎么做按钮连接吗?我认为它应该是一个动作,但我不知道在代码中放在哪里
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
func sendEmail() {
let mailVC = MFMailComposeViewController()
mailVC.mailComposeDelegate = self
mailVC.setToRecipients([])
mailVC.setSubject("Subject for email")
mailVC.setMessageBody("Email message string", isHTML: false)
presentViewController(mailVC, animated: true, completion: nil)
}
// MARK: - Email Delegate
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
controller.dismissViewControllerAnimated(true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Run Code Online (Sandbox Code Playgroud) mfmailcomposeviewcontroller ×10
ios ×5
iphone ×5
objective-c ×5
email ×3
swift ×2
boilerplate ×1
colors ×1
ios13 ×1
ios4 ×1
ios6 ×1
ios7 ×1
message ×1
messageui ×1
toolbar ×1
uiappearance ×1
xcode ×1
xcode11 ×1