Reputation: 289
I have a UITableView
with a TabBar
.
When I click a cell it takes me to a new view, and when I click "Back"
I am back to the previous UITableView
.
Only this time, the TabBar
doesn't show. How can I make it appear again ?
Notice: The left-most view is the view shown when clicking a cell
View A and B
After clicking "Back" - UITabBar gone
Upvotes: 1
Views: 1090
Reputation: 844
If you set your "back" button manually, just set your "back" segue's destination from viewController to navigationController.
But the correct way to use TabBar and NavController is like this:
With this setup, it should work.
class ViewController: UIViewController {
var array = ["one", "two", "three"]
@IBOutlet weak var table: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
extension ViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = array[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "goToDetail", sender: self)
}
}
EDIT
Since you hide your tabBar in view B, you need just unhide it.
Add this code to your view B
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.tabBarController?.tabBar.isHidden = false
}
Upvotes: 3