0

I have implemented UIDocumentInteractionController for previewing unsupported filetypes. But since UIDocumentInteractionController is subclass of NSObject and not UIViewController, I am not able to add it as childviewcontroller of present onscreen UIViewController, as its view property is not exposed.

I can only present it as modal or over navigation stack and not as inline UIView subview.

Tried QLPreviewController but it doesn't support file icons and other useful exposed methods as exposed in UIDocumentInteractionController

tech savvy
  • 1,417
  • 4
  • 21
  • 42

1 Answers1

0

You can present it over topmostview

UIViewController *topmostview = [self topMostController];

then present it over

topmostview.view <your code to present here>

Code to find topmost view

- (UIViewController*) topMostController
{
    UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;

    while (topController.presentedViewController) {
        topController = topController.presentedViewController;
    }

    return topController;
}
9to5ios
  • 5,319
  • 2
  • 37
  • 65
  • This doesn't solve the purpose as UIDocumentInteractionController doesn't expose a property as view. Hence, I can't add it as [topmostview.view addSubview: docController.view]. – tech savvy Jul 10 '18 at 13:30
  • The link mentioned describes presenting a UIViewController but in problem it is UIDocumentInteractionController whose parent in NSObject and not UIViewController. – tech savvy Jul 12 '18 at 07:11