1

Here's what I've created : [TabBarController]->[NavigationController]->[TableView]. I want to create an new [TableView] that will be pushed when I select a cell in the first UITableView. I tried with a pushViewController method. It works but I can't go back to my first TableView (there is no navigation bar). I also tried with a navigationBar between the 2 UITableView but I received the message "cannot push to a navigation bar". Can anyone guide me ? Thanks

[self.navigationController pushViewController:TableView2 animated:YES]; 

(self is my first UITableView)

Code cracker
  • 3,105
  • 6
  • 37
  • 67
Zoomzoom
  • 189
  • 3
  • 13
  • Please a code where you call `pushViewController` – sha Jan 22 '14 at 20:13
  • [self.navigationController pushViewController:TableView2 animated:YES]; (self is my first TableView) – Zoomzoom Jan 22 '14 at 20:20
  • You're mixing views and view controllers. Is tableView2 your view controller? – sha Jan 22 '14 at 20:26
  • I have 2 views (TableView1 et TableView2) et 2 view controllers(navigation controller and tab bar controller) – Zoomzoom Jan 22 '14 at 20:31
  • You need to have UITableViewController containing your TableView2. And push that controller into Navigation controller and not the view itself. – sha Jan 22 '14 at 20:34
  • yes sorry I am mixing view and view controllers. I have only view controllers. – Zoomzoom Jan 22 '14 at 20:52
  • Then you need to post some code on how exactly you're creating second view controller. If you just call `push...` it should do exactly that, and you should still have navigation bar. – sha Jan 22 '14 at 21:06
  • I created the TabBarController(embedded), NavigationController(embedded)and TableViewcontroller in the interface builder. The aim is to display a new TableView when you click on a cell in the TableViewcontroller. That's why I created a new TableViewController and tried to push it.But maybe the best solution is to display a new TableView in the first TableViewcontroller. What do you think? – Zoomzoom Jan 22 '14 at 21:35
  • like mentioned by [sha](http://stackoverflow.com/users/274519/sha), can you post the code which you used to create the `TableView2 View Controller` ? and where exactly are you writing this line `[self.navigationController pushViewController:TableView2 animated:YES];` ? – GoGreen Jan 24 '14 at 09:52
  • Please post relevant code so as to analyse it and we can provide you a solution. – Jassi Mar 28 '15 at 07:42

1 Answers1

0

UINavigationControllershould exist before firstTableViewController. When the cell on firstTableViewis pressed, it should send an event toTableViewmaking use of delegate. After, push the secondTableViewController. After that, you can pop back to firstTableViewControllerfrom the secondTableViewController`.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
snowm1344
  • 127
  • 4