Open SeanMurphy15 opened 8 years ago
You can override customViewForEmptyDataSet:
and return a UIActivityIndicatorView
while your controller is fetching data.
- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView {
if (self.isLoading) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
return indicator;
}
return nil;
}
Awesome! That works! However, when I have an empty array for my tableview the indicator spins forever.
What's the best way to disable the custom UIActivityIndicatorView and display my EmptyDataSet when there is no data?
Not sure what you mean, you can just make sure isLoading
is false and reload your tableView
with the empty array.
Any time customViewForEmptyDataSet:
returns nil, the standard empty state will be shown.
Ok, I'm coding in Swift. Is there an equivalent to isLoading
?
You have to implement isLoading
yourself regardless if you use Swift or Objc.
It may be better to post a question on StackOverflow if you can't get this to work, because this isn't an issue with DZNEmptyDataSet.
Good call. Thanks for the help @bartvandendriessche !
@bartvandendriessche what is a good place to implement isLoading?
Hey ya'll!
Currently, my problem is that the EmptyDataset view appears while my tableview is fetching data. Then it disappears while the tableview gets data. Ideally, I'd like an activity indicator to appear while the data is being fetched and to have the EmptyDataset view appear only if there's no data to present.
I could use GCD with a time interval to give my tableview time to load data while presenting the activity indicator view. However, I feel that's kind of hacky. Is there a delegate method that I'm missing? Thanks in advance!