DZNEmptyDataSet icon indicating copy to clipboard operation
DZNEmptyDataSet copied to clipboard

extra verticalOffsetForEmptyDataSet: after -reloadData

Open Pitometsu opened this issue 9 years ago • 2 comments

I use custom view for loading view case

- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView
{
    if (! self.viewModel.loading) {

        return nil;
    }
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc]
                                             initWithActivityIndicatorStyle:
                                             UIActivityIndicatorViewStyleWhiteLarge];
    [activityView startAnimating];

    return activityView;
}

and default view for empty state view.

Both have vertical offset

- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
    CGFloat offset = CGRectGetHeight(self.navigationController.navigationBar.frame);
    offset += CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);

    if (! self.viewModel.loading) {
        offset += 72.f;
    }
    return -offset;
}

Also, I reload table to change empty placeholder from custom activity to empty placeholder

- (void)initialBind
{
    [RACObserve(self, viewModel.loading) subscribeNext:
     ^(id _Nullable __unused _) {
         [self.tableView reloadData];
     }];
}

As result, I got sum of both vertical offsets.

Pitometsu avatar Jan 17 '17 15:01 Pitometsu

...So I forsed to do hotfix like that:

- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
    CGFloat offset = CGRectGetHeight(self.navigationController.navigationBar.frame);
    offset += CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);

    if (! self.viewModel.loading) {
        offset *= 2; // !!! <== HOTFIX
        offset += 72.f; // actually I need only this
    }
    return -offset;
}

Pitometsu avatar Jan 19 '17 04:01 Pitometsu

Read #147

chuninator avatar Nov 02 '17 05:11 chuninator