8

I have a table view. On 3D Touch I preview a pdf in a QLPreviewController. The peek and the pop work as intended.

For some reason I cannot get the preview controller view to slide up and show my action items. I am returning a valid array of UIPreviewActionItems in (NSArray<id<UIPreviewActionItem>> *)previewActionItems.

For some reason when peek is displayed, no amount of sliding upward moves the preview and no action items are made visible as I see in other apps.

Dean Davids
  • 4,174
  • 2
  • 30
  • 44

4 Answers4

34

I was stuck on this for a while too. Make sure your -previewActionItems method is in the view controller that you are previewing.

Documentation for -previewActionItems

Colin
  • 586
  • 4
  • 8
  • I had this thought. Pretty sure I tried it with no joy. I will double check it, perhaps I never tested it properly. Thanks. – Dean Davids Oct 30 '15 at 19:28
  • 1
    "that you are previewing" I've been stuck on this for so long and you just solved it for me. Thanks. – ecnepsnai Dec 14 '15 at 03:25
7

I had the same issue and was returning the -previewActionsItems from my preview view controller.

I forgot that I was wrapping this in a UINavigationController which is technically the view controller doing the previewing. I dropped this in a subclass to work round it:

- (NSArray<id<UIPreviewActionItem>> *)previewActionItems
{
    return self.topViewController.previewActionItems;
}
Neonkoala
  • 392
  • 2
  • 5
2

previewActionItems should add in the ViewController which you want Preview not in the ViewController registerForPreviewingWithDelegate

Bill Xie
  • 105
  • 6
2

Now you need to override a property rather than a function.

override var previewActionItems: [UIPreviewActionItem] {
    return previewActions
}
Noot
  • 44
  • 1
  • 3