Search code examples
iosswift3dtouch

Add preview actions to peek


For some reason this won't work.

I am trying to add preview actions to my peeked view controller. This view controller is created programmatically and does not actually exist in a file.

I have a regular ViewController, and I cannot override func previewActionItems() -> [UIPreviewActionItems]

It simply does not show up, and it won't compile because it's got nothing to override.

All tutorials I have found are from Swift 2, and I am using Swift 3


Solution

  • In Swift 3, previewActionItems became an overridable variable. Try this:

    override var previewActionItems: [UIPreviewActionItem] {
        return ...
    }