将多个项目粘贴到邮件时,UIPasteboard会截断字符串 [英] UIPasteboard truncating strings when pasting multiple items into Mail

查看:95
本文介绍了将多个项目粘贴到邮件时,UIPasteboard会截断字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用尝试将图像和文本作为一系列项目依次复制到粘贴板.

My app attempts to copy images and text in sequence to the pasteboard, as a series of items.

我发现将文本字符串从粘贴板粘贴到Mail时,它们在第一个"\ n"字符处被截断了.

I am finding that text strings are truncated at the first "\n" character when they are pasted from the pasteboard into Mail.

我认为这与编码有关,但是很奇怪的是,它可以在复制到粘贴板的第一个字符串中很好地处理这些"\ n"字符,这只是后续字符的问题.

I would think it was to do with the encoding, but the weird thing is that it handles these "\n" characters just fine in the first string copied to the pasteboard, it is only a problem with subsequent ones.

NSMutableArray *clipArray=[[NSMutableArray alloc] init];
  for (int i=0;i<[addressList count];i++) {
    NSDictionary *current=[addressList objectAtIndex:i];
    NSString *text= [NSString stringWithFormat:@"%@\n",[current objectForKey:DATA_KEY] ];           
    NSDictionary *item=[NSDictionary dictionaryWithObjectsAndKeys:text,(NSString *)kUTTypeUTF8PlainText,nil];           
    [clipArray addObject:item];
  }
pasteboard.items=clipArray;
NSLog (@"%@",clipArray);

NSLog会完整打印所有字符串,因此我知道它们将存储在粘贴板上.它们还将完整长度粘贴到Pages中.

The NSLog prints all strings at full length, so I know they are being stored in the pasteboard. They also paste at full length into Pages.

您知道为什么Mail应用程序应对此区别对待吗?

Any idea why the Mail app should treat this differently?

推荐答案

您正在打印出阵列的nslog. 尝试打印出pasteboard.items,您将看到问题所在.

you are printing out the nslog of the array. try printing out the pasteboard.items and you'll see what the problem is.

这篇关于将多个项目粘贴到邮件时,UIPasteboard会截断字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆