Pregunta

It seems that the OS chooses whether to use a PNG or JPEG for reasons unknown. In my case, I want a JPEG sent (via mail, twitter, etc.) but I tend to get a very large PNG.

If I subclass UIActivityItemProvider and return an NSURL pointing to a file that I created myself by writing a JPEG to disk using UIImageJPEGRepresentation, I can of course get a JPEG. However using an NSURL causes other issues (one of them being the inability to use iMessage as a target). Is there any way to use a UIImage, but specify that you would prefer a certain file format? (I'm quite sure the answer is NO, but want to check.)

¿Fue útil?

Solución 2

Looks like the answer is indeed NO.

Otros consejos

Actually it just worked to pass in the NSData of the JPEG representation as the activity item.

NSData *data = UIImageJPEGRepresentation(image, 0.6);
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[data]];
                                                                                 applicationActivities:nil];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top