UIActivityViewController => LaunchServices: invalidationHandler called

别来无恙 提交于 2019-12-29 00:35:11

问题


I am playing around with the idea of Airdrop. There is an error while running the sample code by Apple:

https://developer.apple.com/library/ios/samplecode/sc2273/Introduction/Intro.html

The error message is:

LaunchServices: invalidationHandler called

The problem is obviously caused by UIActivityViewController. The related code is under #pragma mark - Actions of this file if you could have a look.

It only show the error message when running on devices (both iPhone and iPad). It is all fine if running on simulator (both iPhone and iPad). What's the cause of this? Any idea about how to resolve it? Could it be possibly a bug?

Similar questions are asked by the following, none of which seems to be able to answer this quesition:

LaunchServices: invalidationHandler called - iOS 8 share sheet

Sharing via UIActivityViewController to Twitter/Facebook etc. causing crash

Present UIActivityViewController- LaunchServices:invalidationHandler called


回答1:


This is a bug on Apple's side. From the developer forums:

That log message does not indicate any error on your part.




回答2:


You have to get rid of the if statement that calls "isAvailableForServiceType:". It should look something like this. Good luck!

    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/26183334/uiactivityviewcontroller-launchservices-invalidationhandler-called

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