0
votes

enter image description here

I did search something similar with my question, but didn't find anything to help me solve my issue.

Is it possible to set behavior for navigation bar item as tab bar item?

I use TabBarController. Each tab item should show the corresponding ViewController. When user tap on the item in nav bar it should show the corresponding ViewController too with the bottom tab bar. And this ViewController should be as tab bar controller, but not display tab item in the bottom tab bar.

How I can achieve the scenario describe above? Or any alternative idea how it possible to implement, please! Almost always the top and bottom bars should be visible for each ViewController.

1
You should have two tabBarControllers. First controller will be parent set true for tabBar.isHidden for it, and you should add the similar buttons in every ViewCotroller which will change tabBar.selectedIndex so you will have one ViewController for first item and Second tabBarController which will be child in first tabBarController. Don't hesitate to ask me moreandproff

1 Answers

0
votes

Drag and drop from your bar button item in IB to your class file and define an outlet, then in viewDidLoad create a gesture recognizer, add an action to your gesture recognizer and you are all set. I hope it helps.

class SomeClass: UIViewControler {

let someBarButton:UIBarButtonItem!
  override func viewDidLoad() {
    super.viewDidLoad()

      let tap = UITapGestureRecognizer(target: self, action: #selector(SomeClass.tapFunction))
             someBarButton.addGestureRecognizer(tap)
   }

  func tapFunction() {
    //take me to a view controller
   self.performSegue(withIdentifier: "myIdentifier", sender: self)
  }
}