3
votes

I am trying to figure out why my activity indicator is not showing on my view controller, here is my code below

var activityIN : UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0,0, 50, 50)) as UIActivityIndicatorView
        activityIN.center = self.view.center
        activityIN.hidesWhenStopped = true
        activityIN.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
        activityIN.startAnimating()
1
So the activity indicator is not showing up on the view controller when you run the project?Jordan
How have you added it to the view?Tometoyou
Looking at your code above, I cannot see where you have added your activity indicator to the view. Have you tried adding it to the view?Jordan
Have you tried this 'view.addSubview(activityIN)' ?Jordan
@TimSmith Just to make sure, have you definitely added the activity indicator to the view controller? for example using, view.addSubview(activiyIN) ?Jordan

1 Answers

8
votes

Try this , see the last line you have forget that

var activityIN : UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(100 ,200, 50, 50)) as UIActivityIndicatorView
activityIN.center = self.view.center
activityIN.hidesWhenStopped = true
activityIN.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
activityIN.startAnimating()
self.view.addSubview(activityIN)