1

I have some swift code for an iOS app that looks like this:

 @IBOutlet weak var activity: UIActivityIndicatorView!

 @IBAction func Button(_ sender: Any) {
     activity.isHidden = false
     activity.startAnimating()

     [My code]

     activity.stopAnimating()
     activity.isHidden = true
 }

But when the function is running the activity indicator doesn't appear, and if I remove:

activity.stopAnimating()
activity.isHidden = true

It will appear when the function is done, so in some way the activity indicator first appears when the function have finished(?)

So my question is: How do I make the activity indicator view stay active only when the function is running?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Harcker
  • 151
  • 1
  • 13

0 Answers0