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?
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?
Try this, You have to call both methods to reload view, as this one works for me,
-Objective-C
-Swift
Update the data ... change button titles..whatever stuff you have to update..
then just call
Direct to your ViewController again. in my situation
[self.view setNeedsDisplay];
and[self viewDidLoad]; [self viewWillAppear:YES];
does not work, but the method below worked.In objective C
Swift:
If you want to reload a ViewController initially loaded from a XIB, you can use the next UIViewController extension:
if you know your database hasbee updated and you want to just refresh viewcontrolle(which is mine case too). i didnt find anyother solution but what i did is when my database updated i called
again, and it worked. remember if you override other viewWillAppear or loadView then call them too in same order. like.
but i think there should be a more specific solution like refresh button in browser. if anyone have plz upload anse
It is not advised to call ViewDidLoad or ViewWillAppear by yourself.
In the ViewDidLoad include a loadData() function to prepare the data. This is executed in the initial run.
When you want to reload, call loadData() again to get the data from model. In a tableView call reloadData() or in a regular view setNeedsDisplay().