Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pasteboard - copying (image + text) creates mystery \n line break

When I add an image and a string to the pasteboard I get a mysterious line break at the start of my text?

NSMutableDictionary *photo = [NSMutableDictionary dictionary];
NSMutableDictionary *text = [NSMutableDictionary dictionary];
NSData* imageData = UIImagePNGRepresentation(theImage.image);
[photo setValue:imageData forKey:(NSString*)kUTTypePNG];
[text setValue:theText.text forKey:(NSString *)kUTTypeUTF8PlainText];
[[UIPasteboard generalPasteboard] setItems:[NSArray arrayWithObjects:photo, text, nil]];

It puts the photo at the top and then it puts a line break and then the text. If I try to send the image and text in an iMessage the image separates anyways and I end up with the text in a bubble with a silly looking line-break infront of it.

If I just copy the text without the photo it does not add a mysterious line-break.

[[UIPasteboard generalPasteboard] setItems:[NSArray arrayWithObjects:text, nil]];

Does anyone know how to fix this?
If not, can anyone think of some nice workaround? Are there any unicode characters that will reverse a line-break? etc?

like image 834
Albert Renshaw Avatar asked Nov 03 '22 22:11

Albert Renshaw


1 Answers

Store PNG as BASE64 encode. See if this helps.

like image 166
ares777 Avatar answered Nov 15 '22 05:11

ares777