-1

I have a two tabbed application, on the first page the user can enter names one at a time, on the second tab, the names are shown in a TableView. I have the code to add the names array to the tables in the ViewDidLoad() func, however, this means that once the user has visited the second tab, when they go back to the first and add more names, they are not shown in the list because the list was populated in ViewDidLoad(), and the tab has already been loaded.

What I am asking for is, what is the name of the func that lets me do this? Something along the lines of IsSelectedTab, but I can't find it.

Jeffrey Bosboom
  • 13,313
  • 16
  • 79
  • 92
James Walker
  • 69
  • 1
  • 8

2 Answers2

1

You are looking for viewWillAppear or viewDidAppear, they are called every time before/after the viewcontroller is about to be visible.

Dániel Nagy
  • 11,815
  • 9
  • 50
  • 58
0

ViewDidLoad() is called once, when the view Initialises while ViewDidAppear() is called every time the view goes on screen and ViewDidDisappear() is called when the view goes off screen.

A solution to achieve your goal would be to use ViewDidAppear() and/or ViewDidDisappear() to populate your list.

leonardo
  • 1,686
  • 15
  • 15