Search code examples
iosobjective-cuitableviewuiactivityindicatorview

How do I add an activity indicator view to my UITableViewController programmatically?


I have a UITableViewController that I need to add an activity indicator view to. I want the activity indicator to animate until the tableview has loaded. I've tried [self.view addSubview:self.activityIndicator]; but it doesn't appear. What should the activity indicator's parent view be?


Solution

  • I'm not sure which part of this solved my problem, but I think it was giving the activity indicator view a frame that fixed it.

    UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        activityIndicator.center = self.view.center;
        [self.view addSubview:activityIndicator];
        [activityIndicator startAnimating];