Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentInteractionController broken in iOS 8

The related code below worked perfect when i was building for iOS 7, but it seems now in iOS 8, it's not working properly.

By properly, I mean in the sense where it's not actually sending the file or whatever to the chosen app.

Example: If I selected Mail, it would open the mail app with the image or zip I chose in the text field. Now it won't send and it takes forever to call/dismiss the UIDocumentInteractionController.

What am I doing wrong?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];

    NSString *fileName = [directoryContents objectAtIndex:indexPath.row];
    NSString *path;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Downloads"];
    path = [path stringByAppendingPathComponent:fileName];


    documentController = [[UIDocumentInteractionController alloc] init];
    documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
    [documentController setDelegate:self];
    [documentController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
    [documentController retain];

}
like image 382
ChrisOSX Avatar asked Nov 26 '25 04:11

ChrisOSX


1 Answers

I have been playing around with the UIDocumentInteractionController and Delegate trying to fix a similar problem, the controller opened-up alright but selecting an application caused it to close without doing anything, my delegate method documentInteractionControllerDidDismissOpenInMenu also run alright afterwards.

In the console i got the notification enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.

It turns out that this problem will accrue when one of these delegate methods is called :

documentInteractionControllerDidDismissOpenInMenu
documentInteractionControllerDidDismissOptionsMenu

(and possibly others, i did not check all of them)

I did not find any comment in the IOS Development Library or the UIDocumentInteractionController.h about these methods not supported for IOS 8.1 but at this point i cant find any other explanation.

Solution :

i replaced documentInteractionControllerDidDismissOpenInMenu with didEndSendingToApplication and it solved the problem for me.

like image 137
MichaelB Avatar answered Nov 28 '25 22:11

MichaelB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!