Hi,
Is it possible to force reload a tableview data? I tried tableView.reload, but this does not seem to work. A few key points:
1) I have a pickerView within a child view that only covers the bottom of the screen & the TableView VC is always visible, so using ViewWillAppear / ViewDidLoad does not work.
2) The data is contained within a model file, and all I am doing is updating the model data.
3) The issue appears to be that once I dismiss the child VC that I cannot figure out a way to "reload" the tableview cells.
4) Using Xcode 11 and Swift 5.2, and I am not using Storyboard.
Here's the code that I am using to go between the main & child views.
From the ViewController:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
addChild(pickerVC)
view.addSubview(pickerVC.view)
pickerVC.didMove(toParent: self)
setupChildConstraints()
}
From the PickerView / Child VC to update data and pass it back to the main VC:
@objc private func updateType() {
if selectedFrequency != "" {
let vc = ViewController()
vc.didTapAdd(type: selectedFrequency)
view.willMove(toWindow: nil)
view.removeFromSuperview()
}
}
And finally, where I am attempting to reload the tableview from the main VC:
extension ViewController: PDSelectFreqDelegate {
func didTapAdd(type: String) {
print(type)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
Any help would be appreciated, thanks.
Post
Replies
Boosts
Views
Activity
Hi,
I am trying to use a Local Notification Action to update my app while it's terminated. I am just trying to update data when the Local Notification triggers.
The documentation that I reviewed mentions to use 'didFinishLaunchingWithOptions,' but from what I understand this only works for Push / Remote Notificaitons. So, I am using 'UNUserNotificationCenter, didReceive...' to work with Action. The UNUserNotificationCenter/didReceive works great if the app is in the background / running.
If its possible, how do I launch / run a background process when the user clicks on an Action trigger?
Thank you in advance,