I am trying to show a simple activity indicator when my view controller loads until a segue is performed. I want to start the activity indicator on viewDidLoad
but I have had no luck so far.
This is the code I was trying to use:
import UIKit
class LoadingScreen: UIViewController {
//Activity indicator view
@IBOutlet weak var activityIndicatorView: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
//start animating
self.activityIndicatorView.startAnimating()
}
}
I get an error: EXC_BAD_INSTRUCTION
which I assume means there's a problem with the code I'm using.
I then stop it after a function called delay:
delay(2.5) {
self.activityIndicatorView.stopAnimating()
}
Assuming the IBOutlet is working correctly (as mentioned in your comment above). You probably want to
stopAnimating
youractivityIndicatorView
within theprepareForSegue:sender:
method.