简体   繁体   中英

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?

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM