问题
My app attempts to copy images and text in sequence to the pasteboard, as a series of items.
I am finding that text strings are truncated at the first "\n" character when they are pasted from the pasteboard into Mail.
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);
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.
Any idea why the Mail app should treat this differently?
回答1:
you are printing out the nslog of the array. try printing out the pasteboard.items and you'll see what the problem is.
来源:https://stackoverflow.com/questions/7444590/uipasteboard-truncating-strings-when-pasting-multiple-items-into-mail