I have an image that I took from the camera and saved in the / tmp folder.
When I add this image to the activity ofIIActivityViewController elements and then click to share it with Twitter or Facebook, I need to wait up to 20 seconds for the sharing dialog to appear.
Note that I am referring to the actual Publish dialog box that appears for Twitter / Facebook, and not the pop-up name of the native resource that spawns it.
When I use the same image from the Photos application, it appears instantly.
At first, I thought the Photos app changed the size of the image because a smaller image appears faster, but I found that when I share a single image directly on Twitter or Facebook using SLComposeViewController, it appears (almost) instantly.
Assuming that I am doing something wrong in the code, this is what leads to the dialog box appearing slowly:
NSArray *items = @[@"foo", [UIImage imageWithContentsOfFile:@"valid path to test image"]]; UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; [self presentViewController:vc animated:YES completion:nil];
It works almost instantly here:
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [controller setInitialText:@"foo"]; [controller addImage:[UIImage imageWithContentsOfFile:@"valid path to test image"]]; [self presentViewController:controller animated:YES completion:Nil];
For what it's worth, I also tried to exclude other types of partitions (I read that there were problems in AirDrop's past problems) as well as wrapping the block to ensure that I execute the main thread.
I assume that I am doing something wrong?
If I am not, and these two other methods actually resize the image, is there some kind of documentation that I skip that gives recommendations on how many changes I need to make?
** Editing: additional testing seems to show that this problem is unique to iOS8 since I did not test it on an earlier iOS7 device.
thanks