UIDocumentInteractionController takes long time to show options
Asked Answered
Z

5

11

I have used UIDocumentInteractionController for sharing the files but it open menu options after 25 seconds in iOS 8 beta 5 and works fine in iOS 7.1.

I have verified the log which I pasted below

Errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo=0x79bd5ef0 {NSLocalizedDescription=query cancelled}
2014-08-27 15:02:05.634 Localwire[82067:1364165] Unknown activity items supplied: (
        {
        "com.microsoft.excel.xls" = <d0cf11e0 a1b11ae1 00000000 00000000 00000000 00000000 3e000300 feff0900 06000000 00000000 00000000 10000000 01000000 00000000 00100000 cb070000 01000000 feffffff 00000000 00000000 62000000 e3000000 64010000 e5010000 66020000 e7020000 68030000 e9030000 6a040000 eb040000 6c050000 ed050000 6e060000 ef060000 70070000 ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff

Im not sure what's the problem is.

Zayin answered 27/8, 2014 at 10:5 Comment(4)
I'm having the same problem using UIActivityViewController to present the share menu. Have you found any solutions?Fustic
I have the same problem with some exotic video formats, pdf and doc files using UIDocumentInteractionController. In my case I get a memory warning and I couldn't find a solution so far. It's bad to hear that UIActivityViewController have the same issue.Urgent
@user2163024 I couldn't find any solution. Im thinking to open the doc in UiDocument preview controller where the share is working fineZayin
@CalinChitu user2163024 instead of it I have used UIActivityViewController which didn't shown up any problem. This bug is still present in iOS 8 GM so I'm going with UIActivityViewController fix.Zayin
Z
2

I have used UIActivityViewController which didn't shown up any problem. This bug is still present in iOS 8 Release version

So I'm going with UIActivityViewController fix.

I have used TYOpenInAppActivity to show the third party apps in UIActivityViewController

NSURL *URL = [NSURL fileURLWithPath:filePath];
TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andBarButtonItem:barButton];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[openInAppActivity]];
    // Create pop up
    self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
    // Store reference to superview (UIPopoverController) to allow dismissal
    openInAppActivity.superViewController = self.activityPopoverController;
    // Show UIActivityViewController in popup
    [self.activityPopoverController presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

You can find the TTOpenInAppActivity controller in below link.

https://github.com/honkmaster/TTOpenInAppActivity

Zayin answered 23/9, 2014 at 9:7 Comment(3)
Did you try open a pdf file with UIActivityViewController?Raddy
I tried. Also passed the custom page renderer to the activityItems. This brings the error "Unknown activity item" though handled properlySprout
@KateGeld The problem with UIActivityController was it doesn't show all the third party application. I have made some more modifications to it to support third part applications also.. I have edited my answer please check thatZayin
I
3

UIActivityViewController is very fast in iOS 8. However you can't open images in other 3rd party applications like Instagram, Vintiqu, and so forth.

Also, presentOpenInMenuFromRect is really faster than presentOptionsMenuFromRect in iOS 8 (iOS 8.0.2 too). But, presentOpenInMenuFromRect does not show sharing actions.

I want to provide users with "Save Image, Assign to Contact, Copy, Print, ..." on the sharing view. So, my current workaround is just as below, :(

    if( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
        [self.udic presentOpenInMenuFromRect:CGRectMake(self.view.frame.size.width/2 - 49/2, self.view.frame.size.height-49, 49, 49)  inView:self.view animated:YES];
    } else {
        [self.udic presentOptionsMenuFromRect:CGRectMake(self.view.frame.size.width/2 - 49/2, self.view.frame.size.height-49, 49, 49)  inView:self.view animated:YES];
    }
Incubation answered 30/9, 2014 at 18:57 Comment(1)
the problem with you're answer is presentOpenInMenuFromRect doesn't show up the options like mail, airdrop and iMessage.Zayin
Z
2

I have used UIActivityViewController which didn't shown up any problem. This bug is still present in iOS 8 Release version

So I'm going with UIActivityViewController fix.

I have used TYOpenInAppActivity to show the third party apps in UIActivityViewController

NSURL *URL = [NSURL fileURLWithPath:filePath];
TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andBarButtonItem:barButton];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[openInAppActivity]];
    // Create pop up
    self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
    // Store reference to superview (UIPopoverController) to allow dismissal
    openInAppActivity.superViewController = self.activityPopoverController;
    // Show UIActivityViewController in popup
    [self.activityPopoverController presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

You can find the TTOpenInAppActivity controller in below link.

https://github.com/honkmaster/TTOpenInAppActivity

Zayin answered 23/9, 2014 at 9:7 Comment(3)
Did you try open a pdf file with UIActivityViewController?Raddy
I tried. Also passed the custom page renderer to the activityItems. This brings the error "Unknown activity item" though handled properlySprout
@KateGeld The problem with UIActivityController was it doesn't show all the third party application. I have made some more modifications to it to support third part applications also.. I have edited my answer please check thatZayin
U
1

My workaround so far is to use presentOpenInMenuFromRect instead of presentOptionsMenuFromRect, this will show less items but at least it's not causing memory issues. QuickLook option seems to be buggy under iOS 8 beta 5 as well, pdf quick look is not working either, beside movie memory issues.

Urgent answered 1/9, 2014 at 7:16 Comment(2)
it didn't worked for me.... instead of that UIAcitivityController was working,....Zayin
the problem with presentOpenInMenuFromRect is it doesn't shows airdrop, mail and iMessage options ... which I needed so I have used UIActivityViewController with using inside activity as TTOpenInAppActivityZayin
O
1

Simple solution: keep the UIDocumentInteractionController as View Controller variable (property or instance var) and init it inside viewDidLoad(in my case I initialized it without any parameters). If the fileURL you want to open is dynamically changes, simply change UIDocumentInteractionController.URL property before presenting.

Oblige answered 27/8, 2015 at 9:13 Comment(0)
A
0

I am running into this with UIActivityViewController, when passing in a dictionary of NSData items that represent PNG images.

I was able to speed up the rendering of the action sheet by converting the NSData objects to UIImage instances in the activityViewControllerPlaceholderItem: method.

- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    NSMutableDictionary *itemPlaceholders = [NSMutableDictionary dictionary];

   [self.items enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSData *obj, BOOL *stop) {
       UIImage *placeholderImage = [UIImage imageWithData:obj scale:.5];
       [itemPlaceholders setObject:placeholderImage forKey:key];
   }];

   return itemPlaceholders;
}
Augmentation answered 24/9, 2014 at 0:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.