Iphone TableView页脚正在与表格一起滚动

Iphone TableView页脚正在与表格一起滚动,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我刚刚在tableView的页脚中实现了一个LoadMore按钮,但是页脚总是随着表格滚动。我的tableView的样式是UITableViewStylePlain 你能告诉我哪里出了问题吗 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footerView = nil; if(footerView == nil) {

我刚刚在tableView的页脚中实现了一个LoadMore按钮,但是页脚总是随着表格滚动。我的tableView的样式是UITableViewStylePlain

你能告诉我哪里出了问题吗

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *footerView = nil;
    if(footerView == nil) {
        footerView  = [[[UIView alloc] init] autorelease];
        footerView.backgroundColor = [UIColor clearColor];
        UIButton *button = [[UIButton alloc] init];    
        button.layer.cornerRadius = 7;
        [button setFrame:CGRectMake(10, 3, 300, 44)];
        [button setTitle:@"Load 20 more" forState:UIControlStateNormal];
        [button.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
        [button setBackgroundColor:[UIColor whiteColor]];
        [button.titleLabel setTextColor:[UIColor blackColor]];
        [button addTarget:self action:@selector(load20More) forControlEvents:UIControlEventTouchUpInside];
        [footerView addSubview:button];
        [button release];
    }
    if ([songInfo count] > 20 && count < 100) {
        return footerView;
    }
    else
        return nil;
}
-(UIView*)表视图:(UITableView*)表视图页脚配置:(NSInteger)部分{
UIView*footerView=nil;
如果(页脚视图==nil){
footerView=[[UIView alloc]init]autorelease];
footerView.backgroundColor=[UIColor clearColor];
UIButton*按钮=[[UIButton alloc]init];
button.layer.cornerRadius=7;
[按钮设置框:CGRectMake(10,3300,44)];
[按钮设置标题:@“加载20多个”状态:UIControlStateNormal];
[button.titleLabel setFont:[UIFont boldSystemFontOfSize:20];
[button setBackgroundColor:[UIColor whiteColor]];
[button.titleLabel setTextColor:[UIColor blackColor]];
[按钮添加目标:自我操作:@selector(load20More)for ControlEvents:UIControlEventTouchUpInside];
[footerView添加子视图:按钮];
[按钮释放];
}
如果([songInfo计数]>20&&count<100){
返回页脚视图;
}
其他的
返回零;
}

首先,
表格视图:viewForFooterInstitution
没有为表格定义页脚,而是为表格中的节定义页脚。一个表中可以有多个节页脚。如果您的表只是一个部分,那么使用此方法在功能上等同于添加表尾,但它并不意味着是表尾。如果您希望使用实际的表尾,那么最好使用实际的表尾,这可以通过简单地将视图分配给
UITableView
tableFooterView
属性来实现


但是,表页脚(节页脚和表页脚)都是为与表一起滚动而构建的。如果您希望实现一个粘在屏幕底部且不随表格滚动的“页脚”,那么最好将
UITableView
的大小调整得更小,以便为“页脚”腾出空间,并添加一个新视图,使其位于刚刚清除的位置。这样,它将固定到位,并且表中的可滚动区域不会与“页脚”重叠。

如果使用内置委托方法中的表视图,
tableView(\utableview:UITableView,viewForFooterInstruction节:Int)->UIView?

它将显示为固定在视图底部,而不关心表视图的高度。即使设置了
tableView.tableFooterView?.isUserInteractionEnabled=true
,它也不会像您所希望的那样工作。因此,作为解决方案,您必须在
viewDidLoad()
上设置表尾视图(在此方法中设置委托和数据源)
let cell=tableView.dequeueReusableCell(标识符为:“MyFinanceTableViewFooterCell”)为!MyFinanceTableViewFooterCell
tableView.tableFooterView=单元格


这将按照您的意愿工作。

当您按load more时,您希望发生什么?load more工作正常,不会影响tableView的页脚随表格滚动。使用情节提要时,如何调整UITableView的大小?您是指在代码中调整大小,还是在xib中调整大小,还是在脚本编辑器中调整大小?我指的是在代码中调整大小。我不使用xib或故事板,你得问问别人。你真的救了我一天!非常感谢。