In my app, i’m getting the data from database. The data that I get from database is very large like 20000 records. So, I want to show an activity indicator to indicate that data is loading. But activity indicator is not showed when I run the app.
I’m sending code for this. Please help me out.
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.frame = CGRectMake(100,100, 20, 20);
[self.view addSubview:activityIndicator];
[activityIndicator startAnimating];
// Code to get data from database
[activityIndicator stopAnimating];
First, you don’t need to set the frame for the activiyIndicator. You can just set the centre…
Second, how are you retrieving the data? Are you doing it all on the main thread? Or are you doing it asynchronously?
::EDIT::
Ah it appears you are doing this…
if this is the case then the stopAnimating will get called almost immediately.
What you need is something like this…
Then in getData…
This way the stop animating will only get called after doing all the data work.
If that doesn’t work try removing the stopAnimating altogether to check it is actually animating in the first place.