Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3D Touch Peek View Will not slide up for action

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.

like image 991
Dean Davids Avatar asked Oct 17 '15 12:10

Dean Davids


4 Answers

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

like image 80
Colin Avatar answered Nov 05 '22 17:11

Colin


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;
}
like image 33
Neonkoala Avatar answered Nov 05 '22 19:11

Neonkoala


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

like image 2
Bill Xie Avatar answered Nov 05 '22 18:11

Bill Xie


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

override var previewActionItems: [UIPreviewActionItem] {
    return previewActions
}
like image 2
Noot Avatar answered Nov 05 '22 17:11

Noot