title: On long press, how do you call an ImagePreviewController: UIViewController from an objective c function instead of a contextMenuInteraction function?
body: <p>This function below needs to instead go into an ObjC function</p>
  <pre><code>///this 1st func is in UITableViewController, the others are in UITableViewCell
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
            if let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;, for: indexPath) as? ViewControllerTableViewCell {
  
   ...}
  
   class ViewControllerTableViewCell: UITableViewCell, UIContextMenuInteractionDelegate
  
  func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -&gt; UIContextMenuConfiguration? {
      UIContextMenuConfiguration(identifier: nil, previewProvider: {
     if self.cc == interaction  {
              let image3 = UIImage(named:&quot;ringy.png&quot;)
              if let unwrappedImage1 = image3 {
                  return ImagePreviewController(image:unwrappedImage1) 
              }
              else {
                  return nil
              }
  
          }
          else if self.vv == interaction{
              let image3 = UIImage(named:&quot;green.png&quot;)
              if let unwrappedImage1 = image3 {
                  return ImagePreviewController(image:unwrappedImage1)   
              }
              else {
                  return nil
              }
          }
  
          else {
                        return nil
                    }
              })
              }
  </code></pre>
  <p>Now Obj C function</p>
  <pre><code>    @objc func didLongPress() {
    ///database call
              if ab as! Int&gt;0 {
   /// here the part for ringy.png needs to go
              } else {
    /////here the part for green.png needs to go
              }
          }
          else {
              print(&quot;No data available&quot;)
          }
      })
  }
  </code></pre>
  <p>ObjC gets handle in override function</p>
  <pre><code>   let longPress = UILongPressGestureRecognizer(target: self, action: #selector(didLongPress))
      like?.addGestureRecognizer(longPress)
  </code></pre>
  <p>What error am I currently getting:</p>
  <p>Non void in void function.  That is if I take the ringy/image3 and green/image3 part of the code and put it is the objC function.</p>
  <p><strong>Update after first answer</strong></p>
  <p>I seem to get it working with the answer and some modifications</p>
  <ol>
  <li>
  <pre><code>weak var viewController: UIViewController?
  </code></pre>
  </li>
  <li>
  <pre><code>viewController?.present(previewVC, animated: true, completion: nil)
  </code></pre>
  </li>
  <li>
  <pre><code>cell.viewController = self ///inside cellForRowAt
  </code></pre>
  </li>
  </ol>
  <p>Only issue I have left is that the dimension of the ImagePreviewController are wrong/virtually full screen. They should be:</p>
  <pre><code>  class ImagePreviewController: UIViewController {
  private let imageView = UIImageView()
  init(image: UIImage) {
      super.init(nibName: nil, bundle: nil)
      imageView.contentMode = .scaleAspectFill
      imageView.clipsToBounds = true
      imageView.image = image
      view = imageView
      let size = UIScreen.main.bounds.size
      preferredContentSize = .init(width: size.width, height: size.height/1.55)
  }
  required init?(coder: NSCoder) {
      super.init(coder: coder)
  }
  </code></pre>