Mohamed Mohsen
Mohamed Mohsen

Reputation: 187

How can i reload/refresh the current tab in the UITabBarController in Swift?


I have a UITabBarController with 2 tabs (map & tableView) like the image below. enter image description here
the problem here i need by pressing the refresh button the tabBar refresh/reload the current tab if it is the map, so refresh the map, if it is the tableView, so refresh the tableView.
just like for the first time when the tabBar instantiate the first tab at the beginning of launching the tabBar.

//i need something like that
self.currentTab.reload()

Upvotes: 1

Views: 1715

Answers (1)

BhargavR
BhargavR

Reputation: 1133

Create a function which contains refresh related code for all the required components and whenever the reload button is clicked then call this function for current view controller. Initially call this function in viewDidLoad(). If every time you navigate to this view controller and you need refreshed data then call this function in viewWillAppear()

Hope this helps.

Upvotes: 1

Related Questions