我创建了一个csv文件并尝试通过电子邮件发送它.显示发送邮件的窗口,但不填充电子邮件正文,也没有附加文件.应用程序挂起此屏幕:
按钮"取消"不起作用.在控制台中出现几秒钟后:
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7f8409f29b50 {Message=Service Connection Interrupted}
<MFMailComposeRemoteViewController: 0x7f8409c89470> timed out waiting for fence barrier from com.apple.MailCompositionService
Run Code Online (Sandbox Code Playgroud)
有我的代码:
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex == 0 {
println("Export!")
var csvString = NSMutableString()
csvString.appendString("Date;Time;Systolic;Diastolic;Pulse")
for tempValue in results { //result define outside this function
var tempDateTime = NSDate()
tempDateTime = tempValue.datePress
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
var tempDate = dateFormatter.stringFromDate(tempDateTime)
dateFormatter.dateFormat = "HH:mm:ss"
var tempTime …Run Code Online (Sandbox Code Playgroud) ios uidocumentinteraction mfmailcomposer uiactivityviewcontroller
这是示例代码:
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBAction func showEmail(sender : AnyObject) {
var emailTitle = "Test Email"
var messageBody = "This is a test email body"
var toRecipents = ["a.nakhimov@gmail.com"]
var mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
self.presentViewController(mc, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError) {
switch result …Run Code Online (Sandbox Code Playgroud) 我有一个棘手的问题.在我的一个应用程序中,有超过150,000次下载...我遇到了一个很少发生的问题,我似乎无法弄明白.
问题如下:在用户可以通过电子邮件共享列表的视图中,我使用打开邮件窗口MFMailComposeViewController.但是,在少数情况下,应用程序似乎使用邮件编辑器出现问题.用户按下共享按钮,邮件窗口向上滑动,等待约1-2秒,然后再次关闭.邮件窗口中没有内容,尽管我确实向其发送数据.我自己无法在任何设备或模拟器中重新创建问题,但是有一位同事.我在他的手机上使用XCode运行应用程序并在日志中获得以下内容:
2013-03-01 14:43:39.604 appname[318:907] <MFMailComposeRemoteViewController: 0x1ebfb100> timed out waiting for fence barrier from com.apple.MailCompositionService
2013-03-01 14:43:39.631 appname[318:907] viewServiceDidTerminateWithError: Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)"
Run Code Online (Sandbox Code Playgroud)
我搜索了错误"从com.apple.MailCompositionService等待栅栏屏障超时",但无法找到任何帮助.
有没有人有这方面的经验?我该如何解决?
我打开视图的代码:
-(void)displayComposerSheetWithBodyString:(NSString *)aBody
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Lista"];
NSString *emailBody = aBody;
[picker setMessageBody:emailBody isHTML:NO];
[self.navigationController presentModalViewController:picker animated:YES];
}
else
{
[[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Din enhet är inte redo att skicka e-post. Kontrollera dina inställningar", nil)
message:nil
delegate:self …Run Code Online (Sandbox Code Playgroud) 情况是MFMailComposeViewController将被呈现.我看到它已经完成了一半,但后来被解雇了.
这是错误:
_serviceViewControllerReady:error:Error Domain = _UIViewServiceInterfaceErrorDomain Code = 3"无法完成操作.(_UIViewServiceInterfaceErrorDomain error 3.)"
这是我提供MFMailComposeViewController的源代码:
-(void) MailExecute {
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:NSLocalizedString(@"Check this new look", @"")];
[mailViewController setMessageBody: @"my new look" isHTML:YES];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
}
else
{
UIAlertView *alertInternal = [[UIAlertView alloc]
initWithTitle: NSLocalizedString(@"Notification", @"")
message: NSLocalizedString(@"You have not configured your e-mail client.", @"")
delegate: nil
cancelButtonTitle:NSLocalizedString(@"OK", @"")
otherButtonTitles:nil];
[alertInternal show];
[alertInternal release];
}
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,有时会发生,有时则不然.请帮帮我!我花了将近1个工作日来解决这个问题,但没有成功.
在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) 我见过这样几个问题,如本但缺乏一个公认的答案,以及根据需要我还是继续面对的课题有实现的事情如下:我显示邮件的作曲家,但在点击取消,作曲家视图冻结.我认为这是由于保存/删除草稿操作表显示在可见框架之外.是的我已经将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
我只是想知道如何在Android中打开Mail Composer.
使用iOS,我会做这样的事情:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setSubject:@"Mail subject"];
[controller setMessageBody:@"Mail body" isHTML:bool];
[controller setToRecipients:recipientsList];
if(controller) [self presentModalViewController:controller animated:YES];
Run Code Online (Sandbox Code Playgroud)
Android怎么样?
非常感谢.
我使用MessageUI框架从我的应用程序发送带附件的邮件.但我得到以下错误,
2009-09-07 19:52:23.483 emailTest[11711:5b17]
Error loading /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator: dlopen(/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator, 265): Library not loaded: /System/Library/PrivateFrameworks/MobileWirelessSync.framework/MobileWirelessSync
Referenced from: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator
Reason: image not found
2009-09-07 19:52:23.489 emailTest[11711:5b17] [+[AccountsManager _migrateAccountsIfNeeded]] Accounts migration failed
[Switching to process 11711 local thread 0xf03]
Run Code Online (Sandbox Code Playgroud)
我的代码是,
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;
[picker setSubject:@"This is iPhone email attachment test"];
UIImage *sampleImg = [UIImage imageNamed:@"iPhone.jpg"];
NSData *imageData = UIImageJPEGRepresentation(sampleImg, 1);
[picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"iPhone.jpg"];
NSString *emailBody = @"I am sending the image attachment with iPhone email service"; …Run Code Online (Sandbox Code Playgroud) 我正在使用MFMailComposer在邮件中发送一些图像.我正在将图像转换为Base64并使用<img>标记将图像添加到HTML正文(我不将其添加为附件).
[htmlString appendFormat:
@"<img src='data:image/png;base64,%@' width=300 height=200 />", imageAsBase64];
Run Code Online (Sandbox Code Playgroud)
图像在MFMailComposer中正确显示,但实际邮件中没有显示从MFMailComposer发送的图像.
我该怎么做才能让它发挥作用?
我注册了自己的自定义CFBundleDocumentTypes文件类型,如以下链接所述:如何在iOS中注册自定义文件类型
一切正常,除非我通过MFMailComposeViewController发送邮件时仍然有这个普通的默认附件图标而不是我自己的.当我收到邮件时,会显示我自己的图标.发送邮件时是否可以更改默认的MFMailComposeViewController附件图标?
谢谢你的帮助,马丁
mfmailcomposer ×10
ios ×6
objective-c ×6
iphone ×4
mfmailcomposeviewcontroller ×4
email ×3
android ×1
gmail ×1
ios4 ×1
ios6 ×1
ios8 ×1
swift ×1