UIActivityViewController completionWithItemsHandler don't call after picking activity items on second try

UIImage *image = self.currentlyDisplayedPhoto.image ? self.currentlyDisplayedPhoto.image : [UIImage imageWithData:self.currentlyDisplayedPhoto.imageData];


UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil];


activityViewController.popoverPresentationController.barButtonItem = sender;

activityViewController.completionWithItemsHandler = ^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {


if (completed && [self.delegate respondsToSelector:@selector(didEndSharingActivityType:)]) {

[self.delegate photosViewController:self didEndSharingActivityType:activityType];

} else {

if ([self.delegate respondsToSelector:@selector(sharingDidOccurAnError:)]) {

[self.delegate photosViewController:self sharingDidOccurAnError:activityType];

}

}

};



if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {

[self presentViewController:controller animated:animated completion:nil];

} else {

controller.popoverPresentationController.barButtonItem = self.rightBarButtonItem;

[self presentViewController:controller animated:animated completion:nil];

}


/*======================================================================

on first attempt sharing an image, the completion block calls, but on the second try it doesnt call (the completion purpose was to dismiss the presented view controller and when the activity type is equal to my share extension)

ps. im sharing it to my own activity item (share extension) to open another view controller but i need to close the presented view controller (Image Picker), and it occurs to some of my images in application NSDocumentDirectory

*/