Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reloading a ViewController

I have a View controller displaying some information (not table views).

I have an update call to a remote server which fills my data base. I would like to completely reload my ViewController after the update call is done.

What should I do?

like image 210
Tiago Veloso Avatar asked Mar 13 '12 14:03

Tiago Veloso


People also ask

What is the difference between viewController and UIViewController?

An UIViewController is just the base class of this already defined "View Controller", you add a viewController as you said, but a viewController has a class associated to it, that can be a UIViewController, UITableViewController, or variations/subclasses.

How do I refresh a tab bar in Swift?

extension Notification.Name { static let refreshAllTabs = Notification.Name("RefreshAllTabs") } class MainTabBarController: UITabBarController, UITabBarControllerDelegate { override func viewDidLoad() { super. viewDidLoad() NotificationCenter. default. addObserver(forName: .


1 Answers

If you know your database has been updated and you want to just refresh your ViewController (which was my case). I didn't find another solution but what I did was when my database updated, I called:

[self viewDidLoad];

again, and it worked. Remember if you override other viewWillAppear or loadView then call them too in same order. like.

[self viewDidLoad]; [self viewWillAppear:YES];

I think there should be a more specific solution like refresh button in browser.

like image 121
Moaz Saeed Avatar answered Sep 21 '22 12:09

Moaz Saeed