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.

Prashanth
  • 463
  • 3
  • 13
  • I'm having the same problem using UIActivityViewController to present the share menu. Have you found any solutions? – mrdziuban Aug 28 '14 at 04:15
  • 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. – Calin Chitu Sep 01 '14 at 06:29
  • 1
    @user2163024 I couldn't find any solution. Im thinking to open the doc in UiDocument preview controller where the share is working fine – Prashanth Sep 01 '14 at 10:11
  • 1
    @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. – Prashanth Sep 11 '14 at 17:35

5 Answers5

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];
    }
alones
  • 2,848
  • 2
  • 27
  • 30
  • the problem with you're answer is presentOpenInMenuFromRect doesn't show up the options like mail, airdrop and iMessage. – Prashanth Nov 15 '14 at 08:29
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

Prashanth
  • 463
  • 3
  • 13
  • 1
    Did you try open a pdf file with UIActivityViewController? – Kate Geld Nov 12 '14 at 15:06
  • I tried. Also passed the custom page renderer to the activityItems. This brings the error "Unknown activity item" though handled properly – Stas Nov 14 '14 at 12:08
  • 1
    @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 that – Prashanth Nov 15 '14 at 08:21
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.

giampaolo
  • 6,906
  • 5
  • 45
  • 73
Calin Chitu
  • 1,099
  • 7
  • 13
  • it didn't worked for me.... instead of that UIAcitivityController was working,.... – Prashanth Sep 11 '14 at 17:35
  • 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 TTOpenInAppActivity – Prashanth Nov 15 '14 at 08:32
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.

kas-kad
  • 3,736
  • 1
  • 26
  • 45
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;
}
user97362
  • 1
  • 1
  • 1