2014-10-09 91 views
2

我試圖從OpenGL視圖(使用libGDX/RoboVM)呈現UIActivityViewController,但我有混合結果。UIActivityViewController不顯示在iPhone + iOS 8

它可以在iOS 7和iOS 8 iPad上正常工作,但在iOS 8 iPhone上,它只是暫停應用程序而不會發生任何事情。除了完成塊從不觸發外,調試日誌中沒有任何註釋。這是代碼:

UIActivityViewController controller = new UIActivityViewController(activityItems, null); 
    List<String> excludedTypes = new ArrayList<String>(); 
    excludedTypes.add("UIActivityTypePrint"); 
    excludedTypes.add("UIActivityTypeAssignToContact"); 
    excludedTypes.add("UIActivityTypeAddToReadingList"); 
    excludedTypes.add("UIActivityTypeAirDrop"); 
    excludedTypes.add("UIActivityTypeCopyToPasteboard"); 
    controller.setExcludedActivityTypes(excludedTypes); 
    IOSApplication iosApplication = (IOSApplication)Gdx.app; 
    // for iPad (https://groups.google.com/forum/#!topic/robovm/fiGDVf6AAsc) 
    int majorOsVersion = Integer.parseInt(System.getProperty("os.version").substring(0, System.getProperty("os.version").indexOf('.'))); 
    if (majorOsVersion >= 8) 
    { 
     UIView sourceView = iosApplication.getUIViewController().getView(); 
     if (width > 0 && height > 0) 
     { 
      UIView subView = new UIView(new CGRect(left, top, width, height)); 
      sourceView.addSubview(subView); 
      sourceView = subView; 
     } 
     UIActivityViewControllerExtensions.getPopoverPresentationController(controller).setSourceView(sourceView); 
    } 
    iosApplication.getUIViewController().presentViewController(controller, true, null); 

我已經驗證,該方法被稱爲「主」線程(希望在libGDX這是同一個主線程在一個CocoaTouch應用程序)

回答

0

NullPointerException異常這裏:

UIActivityViewControllerExtensions.getPopoverPresentationController(controller).setSourceView(sourceView); 

getPopoverPresentationController()在iPhones上返回null,這在Objective-C域中不是問題。

相關問題