只有当表格加载并向下滚动到最后一行时,桌面顶部和表格标题之间仍存在一些差距? [英] Some Gap remains between Table Top and Table Header only when table loads and scrolled down to the last row?

查看:70
本文介绍了只有当表格加载并向下滚动到最后一行时,桌面顶部和表格标题之间仍存在一些差距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:它工作正常,但仍然当表得到负载表顶部和表头之间有一些差距abt 30 pxcls(或1行)..?

It works fine, But still when the table get Loads Some gap remains between table top and table header abt 30 pxcls(or 1 row) ..?

请帮助....

我滚动它工作正常。所有表行都是滚动的,表头是固定的。
但是当我滚动到表的末尾时,它失去了修复的属性。我的意思是边界滚动。我想绝对冻结它。在边界条件下,它会失去桌子的顶部位置并滑动大约20个pxcls。

I am scrolling it works fine. All the table rows are scrolling and table header is fixed. But when I scroll to end of the table it looses its property of fix. I mean is boundry scrolling. I want to freeze it absolutely. At the boundary condition it looses the top position of the table and slides about 20 pxcls.

//Header Format starting
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20.0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section     
{
    if (tableView.tableHeaderView) { // header was already created... go away
        return tableView.tableHeaderView;
    }

    CGFloat width = 300.0f;
    CGRect rectArea = CGRectMake(10.0f, 5.0f, width, 25.0);

    tableView.tableHeaderView = [[[UIView alloc] initWithFrame:rectArea] autorelease];

    //UIColor *orange =  [UIColor colorWithRed:(255.0f/255.0f) green:(228.0f/255.0f) blue:0.0f alpha:1.0f];

    [tableView.tableHeaderView setBackgroundColor:[UIColor grayColor]];

    rectArea = CGRectMake(02.0f, 1.0f, width, 20.0);
    UILabel *lbl = [[UILabel alloc] initWithFrame:rectArea];
    lbl.text = NSLocalizedString(@"Bill Total", @"");
    lbl.textAlignment = UITextAlignmentLeft;
    //lbl.font = [UIFont systemFontOfSize:13.0f];
    lbl.font = [UIFont fontWithName:@"Courier New" size:14];
    lbl.font=[UIFont italicSystemFontOfSize:14];
    lbl.textColor = [UIColor blackColor];
    lbl.backgroundColor = [UIColor clearColor];
    lbl.numberOfLines = 2.0f;
    lbl.lineBreakMode = UILineBreakModeWordWrap;
    //[lbl sizeToFit];

    [tableView.tableHeaderView addSubview:lbl];
    [lbl release];

    // self.table.tableHeaderView.layer.cornerRadius = 6.0f;

    return table.tableHeaderView;
}


推荐答案

如果我正确理解你的问题,听起来你只需要桌子不要反弹。如果是这种情况,您需要做的就是在viewDidLoad函数中设置 yourTable.bounces = NO; 。如果你使用一个来布局你的表,那么或者取消选中NIB中的Bounces选项。

If I understand your question correctly, it sounds like you just need the table not to bounce. If that's the case, all you need to do is set yourTable.bounces = NO; in your viewDidLoad function. Either that or uncheck the "Bounces" option in the NIB if you used one to layout your table.

以下是修复编辑中提到的问题的方法...您需要将以下对tableView.headerView的引用替换为对未被传递的新视图的引用进入委托方法。

Here's how to fix the problem you mentioned in your edit... You need to replace the following references to tableView.headerView with references to a new view that's not being passed into the delegate method.

    UIView *headerView = [[[UIView alloc] initWithFrame:rectArea] autorelease];
    //...    
    [headerView setBackgroundColor:[UIColor grayColor]];
    //...
    [headerView addSubview:lbl];
    //...
    return headerView;

我试过了,它为我做了诀窍。希望有所帮助。

I tried it and it did the trick for me. Hope that helps.

这篇关于只有当表格加载并向下滚动到最后一行时,桌面顶部和表格标题之间仍存在一些差距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆