折合表的上拉加载问题,行数是0,mj_footer不显示,求帮忙

[复制链接]
75 3
折合表,一进页面只显示了所有的区,行数都是是0,只有展开某个区,才会显示该区的所有行数,当所有的行数都是0的时候,mj_footer不显示,只要有行数,才会显示,这样子就没有办法在只有区的时候上拉加载了,这是什么问题?以下是我的代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.


self.view.backgroundColor = ViewBackColor;
self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVBAR_HEIGHT ) style:(UITableViewStylePlain)];
self.tableview.separatorStyle = NO;
self.tableview.delegate = self;
self.tableview.dataSource = self;
[self.tableview registerClass:[DeliveryStatisticHeaderView class] forHeaderFooterViewReuseIdentifier:@"header"];
self.tableview.mj_header = [MJRefreshStateHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
self.tableview.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
[self.view addSubview:_tableview];
currentPage = 1;
[self getUserCouriersDataWithPage:currentPage];

}

-(void)refreshData
{
currentPage = 1;
[self.dataArray removeAllObjects];
[self getUserCouriersDataWithPage:currentPage];
}

-(void)loadMoreData
{
if (dataIsEnd)
{
[self.tableview.mj_footer endRefreshingWithNoMoreData];
}
else
{
currentPage ++;
[self getUserCouriersDataWithPage:currentPage];
}
}



#pragma mark ------- tableView
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.dataArray.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
DeliveryStatisticModel *model = self.dataArray[section];
if (model.isOpen)
{
return 1;
}
return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return Fit5Value(90);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.1;
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return Fit5Value(120);
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.1)];
return view;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
DeliveryStatisticHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"Header"];
if (header == nil)
{
header = [[DeliveryStatisticHeaderView alloc]initWithReuseIdentifier:@"Header"];
}
if (self.dataArray.count != 0)
{
DeliveryStatisticModel *model = self.dataArray[section];
header.model = model;
if (model.isOpen)
{
// [self getCourierSimpleDataWithModel:model];
header.upOrDown.image = [UIImage imageNamed:@"投递统计上"];
}
else
{
header.upOrDown.image = [UIImage imageNamed:@"投递统计下"];
}
}

[header.detailButton addTarget:self action:@selector(DeliveryDetail:) forControlEvents:(UIControlEventTouchUpInside)];
header.detailButton.tag = section;

UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(open:)];
[header addGestureRecognizer:tapGes];
header.tag = section;
return header;
}

-(void)open:(UITapGestureRecognizer *)tap
{
DeliveryStatisticHeaderView *header = (DeliveryStatisticHeaderView *)tap.view;
DeliveryStatisticModel *model = self.dataArray[header.tag];
model.isOpen = !model.isOpen;
if (model.isOpen)
{
if (model.deliveryDict == nil)
{
[self getCourierSimpleDataWithModel:model];
}
else
{
[self.tableview reloadData];
}
}
else
{
[self.tableview reloadData];
}

}

-(void)DeliveryDetail:(UIButton *)detailButton
{
DeliveryStatisticModel *model = self.dataArray[detailButton.tag];
DeliveryDetailController *deliveryDetail = [[DeliveryDetailController alloc]init];
deliveryDetail.statisticModel = model;
[self.navigationController pushViewController:deliveryDetail animated:YES];

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DeliveryStatisticCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell)
{
cell = [[DeliveryStatisticCell alloc]initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:@"Cell"];
}
cell.selectionStyle = NO;
if (self.dataArray.count != 0)
{
DeliveryStatisticModel *model = self.dataArray[indexPath.section];
NSDictionary *dict = model.deliveryDict;
cell.todayDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"today"] integerValue]];
cell.yestDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"yestoday"] integerValue]];
cell.thieWeekDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"week"] integerValue]];
}
return cell;
}

举报 使用道具

回复

3 个评论

bryanen  新手上路  发表于 2018-5-15 14:42:49  | 显示全部楼层
一直看不出来问题,我直接把库更新了,然后别的没有改动就可以了

举报 使用道具

回复
navichen  新手上路  发表于 2018-5-15 15:04:02  | 显示全部楼层
折合表,一进页面只显示了所有的区,行数都是是0,只有展开某个区,才会显示该区的所有行数,当所有的行数都是0的时候,mj_footer不显示,只要有行数,才会显示,这样子就没有办法在只有区的时候上拉加载了,这是什么问题?以下是我的代码
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
  
    self.view.backgroundColor = ViewBackColor;
    self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVBAR_HEIGHT ) style:(UITableViewStylePlain)];
    self.tableview.separatorStyle = NO;
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.tableview registerClass:[DeliveryStatisticHeaderView class] forHeaderFooterViewReuseIdentifier:@"header"];
    self.tableview.mj_header = [MJRefreshStateHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
    self.tableview.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    [self.view addSubview:_tableview];
    currentPage = 1;
    [self getUserCouriersDataWithPage:currentPage];
   
}

-(void)refreshData
{
    currentPage = 1;
    [self.dataArray removeAllObjects];
    [self getUserCouriersDataWithPage:currentPage];
}

-(void)loadMoreData
{
    if (dataIsEnd)
    {
        [self.tableview.mj_footer endRefreshingWithNoMoreData];
    }
    else
    {
        currentPage ++;
        [self getUserCouriersDataWithPage:currentPage];
    }
}



#pragma mark -------  tableView
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.dataArray.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    DeliveryStatisticModel *model = self.dataArray[section];
    if (model.isOpen)
    {
        return 1;
    }
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return Fit5Value(90);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1;
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return Fit5Value(120);
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{

    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.1)];
    return view;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    DeliveryStatisticHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"Header"];
    if (header == nil)
    {
        header = [[DeliveryStatisticHeaderView alloc]initWithReuseIdentifier:@"Header"];
    }
    if (self.dataArray.count != 0)
    {
        DeliveryStatisticModel *model = self.dataArray[section];
        header.model = model;
        if (model.isOpen)
        {
//            [self getCourierSimpleDataWithModel:model];
            header.upOrDown.image = [UIImage imageNamed:@"投递统计上"];
        }
        else
        {
            header.upOrDown.image = [UIImage imageNamed:@"投递统计下"];
        }
    }
   
    [header.detailButton addTarget:self action:@selector(DeliveryDetail:) forControlEvents:(UIControlEventTouchUpInside)];
    header.detailButton.tag = section;
   
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(open:)];
    [header addGestureRecognizer:tapGes];
    header.tag = section;
    return header;
}

-(void)open:(UITapGestureRecognizer *)tap
{
    DeliveryStatisticHeaderView *header = (DeliveryStatisticHeaderView *)tap.view;
    DeliveryStatisticModel *model = self.dataArray[header.tag];
    model.isOpen = !model.isOpen;
    if (model.isOpen)
    {
        if (model.deliveryDict == nil)
        {
            [self getCourierSimpleDataWithModel:model];
        }
        else
        {
            [self.tableview reloadData];
        }
    }
    else
    {
        [self.tableview reloadData];
    }
   
}

-(void)DeliveryDetail:(UIButton *)detailButton
{
    DeliveryStatisticModel *model = self.dataArray[detailButton.tag];
    DeliveryDetailController *deliveryDetail = [[DeliveryDetailController alloc]init];
    deliveryDetail.statisticModel = model;
    [self.navigationController pushViewController:deliveryDetail animated:YES];
   
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DeliveryStatisticCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (!cell)
    {
        cell = [[DeliveryStatisticCell alloc]initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:@"Cell"];
    }
    cell.selectionStyle = NO;
    if (self.dataArray.count != 0)
    {
        DeliveryStatisticModel *model = self.dataArray[indexPath.section];
        NSDictionary *dict = model.deliveryDict;
        cell.todayDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"today"] integerValue]];
        cell.yestDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"yestoday"] integerValue]];
        cell.thieWeekDelivery.text = [NSString stringWithFormat:@"%ld", [dict[@"week"] integerValue]];
    }
    return cell;
}

举报 使用道具

回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

ios.irunthink.com
搜索
热搜: iOS swift 下拉刷新

图文热点

更多

开发教程

更多

客服中心

400-800 周一至周日 9:30-17:30 仅收市话费

关注我们

  • 微信扫描
  • 关注微信
关于我们
关于我们
友情链接
联系我们
帮助中心
精贴推荐
源码上传
注册登录
服务支持
资源下载
关注我们
官方微博
官方空间
快速回复 返回顶部 返回列表