Skip to content

Commit

Permalink
Add no content view when all the cells get deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
mardelean committed Jan 20, 2016
1 parent cf9d3d7 commit 32e0743
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions BIObjCHelpers/Views/TableView/BITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ - (void)setTableFooterView:(UIView *)tableFooterView {
}];
}

- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:animation];
if ([self BI_totalNumberOfRows] == 0 && !self.visibleAdditionalView) {
[self addAdditionalNoContentView];
}
}

- (void)insertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:animation];
if ([self BI_totalNumberOfRows] != 0 && self.visibleAdditionalView) {
[self removeVisibleAdditionalView];
}
}

#pragma mark - Public methods

- (void)triggerPullToRefresh {
Expand Down Expand Up @@ -244,6 +258,19 @@ - (void)BI_createInfiniteScrollingActivityIndicatorContainer {
}
}

- (NSInteger)BI_totalNumberOfRows {
NSInteger numberOfSections = 1;
if ([self.dataSource respondsToSelector:@selector(numberOfSectionsInTableView:)]) {
numberOfSections = [self.dataSource numberOfSectionsInTableView:self];
}

NSInteger totalNumberOfRows = 0;
for (NSInteger sectionIndex = 0; sectionIndex < numberOfSections; sectionIndex++) {
totalNumberOfRows += [self.dataSource tableView:self numberOfRowsInSection:sectionIndex];
}
return totalNumberOfRows;
}

@end


Expand Down

0 comments on commit 32e0743

Please sign in to comment.