Present UIActivityViewController- LaunchServices:invalidationHandler called

我的未来我决定 提交于 2019-12-18 12:33:25

问题


I've already looked at related questions here and here, and I have implemented the suggested answers to no avail.

I have a UIBarButtonItem on a UIToolbar, with Connection for Send Action to btnTBAction_touch:

In the ViewController's class header I have:

@property (nonatomic, strong) UIActivityViewController *activityViewController;

The related method in the class implementation:

- (IBAction)btnTBAction_touch:(id)sender {
    NSString *string = @"Some string";
    NSURL *url = [[NSURL alloc] initWithString:@"http://www.google.com"];
    UIImage *image = [UIImage imageNamed:@"default.png"];
    self.activityViewController = [[UIActivityViewController alloc] 
        initWithActivityItems:@[string, url, image] applicationActivities:nil];

    if ([self.activityViewController respondsToSelector:@selector(popoverPresentationController)])
    {
        UIPopoverPresentationController *presentationController = [self.activityViewController
            popoverPresentationController];
        presentationController.sourceView = sender;
    }

    [self presentViewController:self.activityViewController animated:YES completion:nil];
}

While running in debug mode on a physical device when I touch the button that calls the above method, I get the following in the debug console

2014-09-19 09:43:31.635 TestApp[1878:237873] LaunchServices: invalidationHandler called
2014-09-19 09:43:31.644 TestApp[1878:237814] LaunchServices: invalidationHandler called

However, unlike the related questions my app does not crash when this happens, the app continues to work fine and the UIActivityViewController is presented correctly... but I'd rather fix the bug than say it's good enough.

Additionally I have tried a few permutations of the above method using these lines:

presentationController.sourceView = self.view;

presentationController.sourceRect = self.view.frame;

None of which helped resolve the issue.

  • I'm using Xcode v6.0.1
  • My App's Deployment Target is 7.0 for iPhone only
  • Testing on an iPhone 5s running iOS 8.0
  • Code is all in Objective-C

回答1:


If your development target target device is iPhone you should not worry about this message. It looks like it's a bug from Apple. Looking at the developer forums: "That log message does not indicate any error on your part."

See: https://devforums.apple.com/message/1049415#1049415 (might require you to login)




回答2:


Similar issue here.

I am using UIDocumentInteractionController, not UIActivityViewController, so there is no sourceView or sourceRect to handle.

In the header:

UIDocumentInteractionController *docInteractionController;

In the .m:

self.docInteractionController = [UIDocumentInteractionController  interactionControllerWithURL:fileURL];

self.docInteractionController.delegate = self;
self.docInteractionController.UTI = @"com.adobe.pdf";
//UIBarButtonItem *element is an element in my toolbar
[self.docInteractionController presentOptionsMenuFromBarButtonItem:element animated:YES];

On the console I see the following warning:

 Unknown activity items supplied: (
    {
    "com.adobe.pdf" = <25504446 (and then what looks like the rest of the pdf I tried to open)>;
},
"<UIPrintInfo: 0x17b47ca0>"
 )
 2014-10-14 21:11:21.661 iFly[288:29569] LaunchServices: invalidationHandler called

And in my official App Store version of my app, the app crashes. When I compile and run on my iPad it just gives the warning.

I can get around the "Unknown activity items" supplied part of the warning by using presentOpenInMenuFromBarButtonItem instead of presentOptionsMenuFromBarButtonItem for the UIDocumentInteractionController call, but the "LaunchServices" warning still occurs.

iPad version 8.0.2. Xcode version 6.0.1, deployment target 6.0 (also tested with deployment target 8.0). All objective-c.




回答3:


This is what worked for me. No errors. I had to get rid of the if statement that called "isAvailableForServiceType:". Hope it works for you!

   SLComposeViewController *tweetSheet = [SLComposeViewController
                                           composeViewControllerForServiceType:SLServiceTypeTwitter];

    [tweetSheet setInitialText:@"Great fun to learn iOS programming at appcoda.com!"];
    [self presentViewController:tweetSheet animated:YES completion:nil];

    if ([tweetSheet respondsToSelector:@selector(popoverPresentationController)])
    {
        // iOS 8+
        UIPopoverPresentationController *presentationController = [tweetSheet popoverPresentationController];

        presentationController.sourceView = sender; // if button or change to self.view.
    }


来源:https://stackoverflow.com/questions/25937143/present-uiactivityviewcontroller-launchservicesinvalidationhandler-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!