title: Navigate to View Controller from .xib file swift
body: <p>I have an issue. I have <code>.xib</code> file that am using to render some buttons. I want it such that when each of these buttons is clicked, it navigates to a new <code>viewController.</code> My logic doesnt work for me and i cant figure out what to do since this <code>.xib</code> layout is not embedded in a <code>UIViewController</code>.</p>
  
  <p><strong>explore.xib</strong></p>
  
  <pre><code> import UIKit
  
      protocol ExploreDelegate:UIViewController {
          func categoryClicked(category: ProductCategory)
      }
  
      //enum Categories: String, CaseIterable {
      //
      //}
  
  
      class Explore: UIView {
  
          @IBOutlet weak var electronics: CategoryItem!
          @IBOutlet weak var mobilePhones: CategoryItem!
          @IBOutlet weak var travel: CategoryItem!
          @IBOutlet weak var womenFashion: CategoryItem!
          @IBOutlet weak var menFashion: CategoryItem!
          @IBOutlet weak var health: CategoryItem!
          @IBOutlet weak var arts: CategoryItem!
          @IBOutlet weak var babies: CategoryItem!
          @IBOutlet weak var rentals: CategoryItem!
          @IBOutlet weak var realEstate: CategoryItem!
          @IBOutlet weak var agriculture: CategoryItem!
          @IBOutlet weak var jobs: CategoryItem!
          @IBOutlet weak var everything: CategoryItem!
  
  
          var categoriesView: UIView!
          var titleLabel: UILabel!
          var delegate: ExploreDelegate?
  
          override init(frame: CGRect) {
              super.init(frame: frame)
              self.setup()
          }
  
          required init?(coder aDecoder: NSCoder) {
              super.init(coder: aDecoder)
              self.setup()
          }
  
          func configure() {
              let categoryButtons = [electronics, mobilePhones, travel, womenFashion, menFashion, health, arts, babies, rentals, realEstate, agriculture, jobs, everything]
              let categories: [ProductCategory] = ProductCategory.allCases
              categoryButtons.enumerated().forEach({
                  $0.element?.category = categories[$0.offset]
              })        
              self.layoutIfNeeded()
          }
      }
  
      class CategoryItem: UIView {
  
          var category: ProductCategory? {
              didSet {
                  self.configure()
              }
          }
          var tapped: ((_ category: ProductCategory?) -&gt; Void)?
  
          func configure() {
              self.layer.cornerRadius = 6
              self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.categoryTapped)))
              self.layoutIfNeeded()
          }
  
          @objc func categoryTapped(_ sender: UIGestureRecognizer) {
  //here i want to navigate to new view controller but not working
              let newViewController = ProductLocationViewController()
              self.navigationController?.pushViewController(newViewController, animated: true)
              self.tapped?(self.category)
          }
      }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>value of type 'CategoryItem' has no member 'navigationController'
  </code></pre>
  
  <p>Please helpful ideas would be greatly appreciated. </p>