Marc Murphy
Marc Murphy

Reputation: 11

UIProgressView not updating progress

Simple question, here's the code snippet in question:

override func viewDidLoad()  {
      tableView.sectionHeaderHeight = 0
      self.navigationController?.isNavigationBarHidden = true
      self.parent?.dismiss(animated: true, completion: nil)
      let alertView = UIAlertController(title: "Please wait", message: "Loading stats...", preferredStyle: .alert)
      let progressView = UIProgressView(progressViewStyle: .default)
      alertView.view.addSubview(progressView)
      present(alertView, animated: true, completion: { [self] in
          DispatchQueue.main.async { [self] in
              progressView.progress = 0.0
              print(progressView.progress)
              refreshStatData()
              progressView.progress = 0.5
              print(progressView.progress)
              refreshStatDisplay()
              progressView.progress = 1.0
              print(progressView.progress)
              alertView.dismiss(animated: true, completion: nil)
              tableView.isHidden = false
          }
      })
  }

Instead of being blank, then half blue and finally completely filled, the progress bar is grey with 50% progress from the beginning, then it turns blue and then it's gone. I'm not familiar with DispatchQueue so any help would be greatly appreciated.

Upvotes: 0

Views: 28

Answers (0)

Related Questions