xhzengAIB / XHRefreshControl

XHRefreshControl 是一款高扩展性、低耦合度的下拉刷新、上提加载更多的组件。
MIT License
736 stars 149 forks source link

XHDemoTableViewController在两页数据条件下loadmore按钮和tableview重叠 #13

Closed luohao-brian closed 10 years ago

luohao-brian commented 10 years ago

将XHDemoTableViewController.m的loadDataSource做如下修改:

1)去掉sleep(1.5), 模拟后台数据快速加载 2)修改为requestCurrentPage==2时,调用endMoreOverWithMessage。

快速pull up, 结果loadmore按钮和tableview重叠.

- (void)loadDataSource{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         NSMutableArray *dataSource = [[NSMutableArray alloc] initWithObjects:
                                  @"请问你现在在哪里啊?我在广州天河",
                                  @"请问你现在在哪里啊?我在广州天河",
                                  @"请问你现在在哪里啊?我在广州天河",
                                  @"请问你现在在哪里啊?我在广州天河",

    NSMutableArray *indexPaths;
    if (self.requestCurrentPage) {
        indexPaths = [[NSMutableArray alloc] initWithCapacity:dataSource.count];
        [dataSource enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            [indexPaths addObject:[NSIndexPath indexPathForRow:self.dataSource.count + idx inSection:0]];
        }];
    }
    //sleep(1.5);
    dispatch_async(dispatch_get_main_queue(), ^{
        if (self.requestCurrentPage) {
            if (self.requestCurrentPage == 2) {
                [self endMoreOverWithMessage:@"段子已加载完"];
            } else {

                [self.dataSource addObjectsFromArray:dataSource];
                [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
                [self endLoadMoreRefreshing];
            }
        } else {
            if (rand() % 3 > 1) {
                self.loadMoreRefreshed = NO;
            }

            self.dataSource = dataSource;
            [self.tableView reloadData];
            [self endPullDownRefreshing];
        }
    });
xhzengAIB commented 10 years ago

您好!那需要怎么改进呢?

luohao-brian commented 10 years ago

将autoLoadMoreRefreshedCountConverManual可以workaround这个问题,但是这样autoload基本就没有效果了,感觉像是一个autoload的bug.

- (NSInteger)autoLoadMoreRefreshedCountConverManual {
     return 1;
}