iphone - 将 UIPasteBoard 中的 vCard 粘贴到邮件中

标签 iphone ios cocoa-touch ipad

我复制一个vcard(包含在bundle中)到通用粘贴板如下:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"AM" ofType:@"vcf"]; 
NSData *data = [NSData dataWithContentsOfFile:filePath];
[[UIPasteboard generalPasteboard] setData:data forPasteboardType:(NSString*)kUTTypeVCard];

然后我希望用户能够将其粘贴到电子邮件中。但是,当它被复制到粘贴板时,Mail 不提供粘贴选项。是我做错了什么还是 Mail 无法识别该粘贴板类型?

最佳答案

你可以像这样直接将它添加到消息中

MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"AM ofType:@"vcf"]; 
NSData *data = [NSData dataWithContentsOfFile:filePath];
[mailViewController addAttachmentData:data mimeType:@"text/vcard" fileName:@"AM.vcf"];
mailViewController.mailComposeDelegate = self;
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];

关于iphone - 将 UIPasteBoard 中的 vCard 粘贴到邮件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9117702/

相关文章:

objective-c - iPhone开发-生成XML文件

ios - 从 iPhone 应用程序中的 iWatch 触发 Action 以控制蓝牙设备

iphone - 适用于 iPhone 的 Sparrow 或 Cocos2D 2D 游戏?

iPhone开发-内存释放问题

ios - 查询没有帐户属性的 IOS Keychain?

iphone - 在单元格之一内编辑 UITextField 时动态重新加载 UITable

iphone - 在 iPhone/iPad 应用程序中发送电子邮件时将默认电子邮件更改为其他电子邮件客户端(在非内置应用程序中)

ios - UITextView 双击编辑

ios - 展开和收缩标签在 UITableViewCell 中不起作用

ios - 网页 View :How to detect if I am on the original web page and execute a certain method