0

I have view with news in tableView, when I change some parameters in settings and return to view with news, my tableView must reloads news depending on new settings. I have outlet activityIndicator and this code :

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Start animating
    indicator.startAnimating()
    indicator.backgroundColor = UIColor.white

    // Load new depending on settings    
    getJsonFromUrl(editionsArray: GlobalSettings.sharedManager.editions.sorted())
    self.tableView.reloadData()

    indicator.stopAnimating()
    indicator.hidesWhenStopped = true
}

Now when tableView is empty I can see activityIndicator, but when my tableView reloads, activityIndicator is not shown on screen.

Enea Dume
  • 3,014
  • 3
  • 21
  • 36
g196et
  • 26
  • 3

2 Answers2

1

Either the ActivityIndincatior behind the table view or table view cell color and activity indicator color will be matching (White in this case).

Also try by setting ActivityIndicator visibility true before animation start.

Hope you have not removed activity indicator form its sueprview.

Sai Prasad
  • 286
  • 1
  • 2
  • 13
0

Thanks for the help. I find the answer. All problems were in the function getJsonFromUrl, because I use a semaphore to wait for loading and parsing json. When I changed the semaphore to DispatchQueue.main.asyncAfter everything started working!

g196et
  • 26
  • 3