wangmchn / WMPageController

An easy solution to page controllers like NetEase News
MIT License
2.92k stars 627 forks source link

设置tableview的底部试图有问题 #584

Open shenshangjimiaoZG opened 5 years ago

shenshangjimiaoZG commented 5 years ago

UITableViewHeaderFooterView 当我把第一个footerview显示出来,多显示了一个footerview,看截图。 img_0078

shenshangjimiaoZG commented 5 years ago

就是温馨提示那里多了一个footerview,不知道为什么?请问要怎么解决?

shenshangjimiaoZG commented 5 years ago

import "HLMarketExchangeBuyViewController.h"

import "HLMarketExchangeTableViewCell.h"

import "HLMarketOrderSectionHeaderView.h"

import "HLOrderTicketTableViewCell.h"

import "ColorConfig.h"

import <Masonry/Masonry.h>

import "HLUserSettingHeaderView.h"

import "HLTableFooterView.h"

@interface HLMarketExchangeBuyViewController ()<UITableViewDelegate,UITableViewDataSource> @property(nonatomic,strong)UITableView *infoTable; @end

@implementation HLMarketExchangeBuyViewController -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)viewDidLoad { [super viewDidLoad];

self.title=@"买入";

self.view.backgroundColor=VC_bgColor;

self.infoTable=[UITableView new];
self.infoTable.dataSource=self;
self.infoTable.delegate=self;
self.infoTable.separatorStyle=UITableViewCellSelectionStyleNone;

[self.infoTable registerNib:[UINib nibWithNibName:kHLOrderTicketTableViewCell bundle:[NSBundle mainBundle]] forCellReuseIdentifier:kHLOrderTicketTableViewCell];

[self.infoTable registerClass:[HLUserSettingHeaderView class] forHeaderFooterViewReuseIdentifier:kHLUserSettingHeaderView];

[self.infoTable registerClass:[HLTableFooterView class] forHeaderFooterViewReuseIdentifier:kHLTableFooterView];

  [self.infoTable registerClass:[HLMarketOrderSectionHeaderView class] forHeaderFooterViewReuseIdentifier:kHLMarketOrderSectionHeaderView];

self.infoTable.showsVerticalScrollIndicator=NO;
self.infoTable.showsHorizontalScrollIndicator=NO;
self.infoTable.backgroundColor=VC_bgColor;
[self.view addSubview:self.infoTable];

if(@available(iOS 11,*))
{
    self.infoTable.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;
}
else
{
    self.automaticallyAdjustsScrollViewInsets=NO;
}

[self.infoTable mas_makeConstraints:^(MASConstraintMaker *make) {

    if(@available(iOS 11,*))
    {
        make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
        make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);

        make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);

    }
    else
    {
        make.top.equalTo(self.view.mas_top);
        make.right.left.bottom.equalTo(self.view);

    }
}];

}

pragma mark table delegate

-(CGFloat)tableView:(UITableView )tableView heightForHeaderInSection:(NSInteger)section { if(section==0) { return 10; } else if (section==1) { return 44; } return 0; } -(UIView)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { NSLog(@"viewForHeaderInSection %ld",section);

if(section==0)
{
    HLUserSettingHeaderView *view=[tableView dequeueReusableHeaderFooterViewWithIdentifier:kHLUserSettingHeaderView];
    if(view==nil)
    {
        view=[[HLUserSettingHeaderView alloc]initWithReuseIdentifier:kHLUserSettingHeaderView];
    }
    return view;
}
else if (section==1)
{
    HLMarketOrderSectionHeaderView *view=[tableView dequeueReusableHeaderFooterViewWithIdentifier:kHLMarketOrderSectionHeaderView];
    if(view==nil)
    {
        view=[[HLMarketOrderSectionHeaderView alloc]initWithReuseIdentifier:kHLMarketOrderSectionHeaderView];
    }
    return view;
}
return nil;

} -(CGFloat)tableView:(UITableView )tableView heightForFooterInSection:(NSInteger)section { if(section==0) { return 10; } return 0; } -(UIView)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {

if(section==0)
{
    HLTableFooterView *view=[tableView dequeueReusableHeaderFooterViewWithIdentifier:kHLTableFooterView];
    if(view==nil)
    {
        view=[[HLTableFooterView alloc]initWithReuseIdentifier:kHLTableFooterView];
    }
    return view;
}
return nil;

} -(CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath { if(indexPath.section==0) { return 410; } else if (indexPath.section==1) { return 270; } return 0; } -(NSInteger)numberOfSectionsInTableView:(UITableView )tableView { return 2; } -(NSInteger)tableView:(UITableView )tableView numberOfRowsInSection:(NSInteger)section { if(section==0) { return 1; } else if (section==1) { return 3; } return 0; } -(UITableViewCell)tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath { if(indexPath.section==0) { HLMarketExchangeTableViewCell cell=[tableView dequeueReusableCellWithIdentifier:kHLMarketExchangeTableViewCell]; if(cell==nil) { cell=[[NSBundle mainBundle]loadNibNamed:kHLMarketExchangeTableViewCell owner:self options:nil].lastObject; } return cell; } else if(indexPath.section==1) { HLOrderTicketTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kHLOrderTicketTableViewCell]; if(cell==nil) { cell=[[NSBundle mainBundle]loadNibNamed:kHLOrderTicketTableViewCell owner:self options:nil].lastObject; } return cell; } return nil; } @end

shenshangjimiaoZG commented 5 years ago

// [[UITableView appearance]setContentInset:UIEdgeInsetsMake(0, 0,200, 0)]; 我只要屏蔽这句话就不显示了。