2014-09-19 29 views
10

我已經看過相關的問題herehere,並且我已經實現了建議的解決方法,但無濟於事。目前UIActivityViewController- LaunchServices:invalidationHandler調用

我有一個UIToolbar一個的UIBarButtonItem,與連接的發送行動btnTBAction_touch:

在視圖控制器的類的頭,我有:

@property (nonatomic, strong) UIActivityViewController *activityViewController; 

的相關方法的類實現:

- (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]; 
} 

當我在調試模式下在物理設備上運行時,當我觸摸調用上述方法的按鈕時,我在d ebug控制檯

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 

然而,與相關的問題,遇到這種情況時我的應用程序不會崩潰,應用程序將繼續正常工作和UIActivityViewController正確呈現......但我寧願修復bug比說,這是夠好了。

另外我一直在使用這些線路試過上述方法的一些排列:

presentationController.sourceView = self.view; 

presentationController.sourceRect = self.view.frame; 

其中沒有幫助解決問題。

  • 我使用的Xcode V6.0.1
  • 我的應用程序的部署目標爲7.0 iPhone只
  • 測試在運行iOS的iPhone 5S 8.0
  • 代碼都是在Objective-C
+0

同樣的問題。 http://stackoverflow.com/questions/25192313/sharing-via-uiactivityviewcontroller-to-twitter-facebook-etc-causing-crash中提出的解決方案不起作用(sourceView或sourceRect)。 – loretoparisi 2014-09-25 09:13:44

+0

同一問題在這裏 – Praksha 2014-09-26 13:41:11

回答

5

如果你的開發目標設備是iPhone,你不應該擔心這個消息。看起來這是來自Apple的一個bug。查看開發人員論壇:「該日誌消息不表示您的任何錯誤。」

請參見:https://devforums.apple.com/message/1049415#1049415(可能需要您登陸)

+0

鏈接?與參考我將這標記爲答案 – chriszumberge 2014-10-10 17:27:51

+0

@chriszumberge我編輯了我的答案,幷包含鏈接 – Eric 2014-10-10 20:29:17

2

類似的問題在這裏。

我正在使用UIDocumentInteractionController,而不是UIActivityViewController,所以沒有sourceView或sourceRect來處理。

在標題:

UIDocumentInteractionController *docInteractionController; 

在.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]; 

在我看到下面的警告控制檯:

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 

而且在我的官方應用程序商店版我的應用程序,該應用程序崩潰。當我在我的iPad上編譯和運行時,它只是發出警告。

我可以通過使用presentOpenInMenuFromBarButtonItem而不是用於UIDocumentInteractionController調用的presentOptionsMenuFromBarButtonItem來提供部分警告的「未知活動項目」,但仍會發生「LaunchServices」警告。

iPad版本8.0.2。 Xcode版本6.0.1,部署目標6.0(也用部署目標8.0測試)。所有的目標-c。

+0

我看到相同的問題。另外,取消菜單選項後,我的操作按鈕似乎不能啓用。不知道這是否與這些錯誤有關。有人可以回答嗎? – Shwethascar 2014-12-04 21:48:00

0

這是對我工作。沒有錯誤。我不得不擺脫名爲「isAvailableForServiceType:」的if語句。希望對你有幫助!

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. 
    } 
+0

'UIDocumentInteractionController'怎麼樣? 'UIDocumentInteractionController'沒有'popoverPresentationController'屬性 – TomSawyer 2014-11-07 18:04:50

相關問題