Question

I have View with TableView, I want to show activity indicator when I do something but he don't show, I found this code:

UIActivityIndicatorView *activityView =
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(120, 230, 50, 50);
[self.ReportTableView addSubview:activityView];

[activityView startAnimating];

No errors but and now indicator show.

Solution:

[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:activityView];
Was it helpful?

Solution

if your tableview backgrond color is white then it will not show because UIActivityIndicatorViewStyleWhite is also white

[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

Change to

[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

OTHER TIPS

Dont add activity inside the tableview.Add it in the main view or the superview of table

Dont forget to update the frame accordingly to where you add it

[self.ReportTableView.superView addSubview:activityView];
[self.ReportTableView.superView bringSubviewToFront:activityView];
// Your code
[activityView startAnimating];

[self.ReportTableView addSubview:activityView];

Move [activityView startAnimating]; after

[self.ReportTableView addSubview:activityView];

Order is very important

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top