Reputation: 5729
This must be super simple, but I cannot find it.
I want to show an NSProgressIndicator
indeterminite spinner style to my NSViewController
to show in the middle of the view while the app starts up (similar to Xcode). Once all data is loaded (on a background thread), I return to the main thread and hide the spinner and show the contents.
Everything works as expected, except, I don't see the spinner.
In the storyboard I added the spinner as a sub view of the main view, and the added the centerX and centerY constraints, also in the storyboard.
Then in viewDidLoad
:
override func viewDidLoad() {
super.viewDidLoad()
progressSpinner.isHidden = false
progressSpinner.startAnimation(self) // <-- do I use self here?
}
and once the data is loaded:
func didFinishLoading() {
progressSpinner.stopAnimation(self) // <-- do I use self here?
progressSpinner.isHidden = true
showData()
}
What am I missing here?
Upvotes: 0
Views: 330
Reputation: 5729
Ok, I found the problem. The "Hidden" checkbox in the storyboard was checked.
Even with progressSpinner.isHidden = false
in viewDidLoad
, the spinner remained invisible. Unchecking that box solved it.
EDIT
The underlying problem I think now is that spinner was obscured by the scrollView in the same window. Changing the order in the storyboard did not help, so I ended up removing and re-adding the spinner as shown below. And now it works independent of the Hidden checkbox setting.
override func viewDidLoad() {
super.viewDidLoad()
progressSpinner.removeFromSuperview()
view.addSubview(progressSpinner, positioned: .above, relativeTo: nil)
progressSpinner.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
progressSpinner.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
progressSpinner.isHidden = false
progressSpinner.isDisplayedWhenStopped = false
progressSpinner.startAnimation(self)
}
Upvotes: 1