2011-09-15 4 views
1

編集:それはうまく動作しますが、まだテーブルがロードを取得するテーブルトップとテーブルヘッダabt 30 pxcls(または1行)の間にいくつかのギャップが残っています..?テーブルトップとテーブルヘッダーの間には、テーブルがロードされて最後のローまでスクロールされたときにだけギャップが残っていますか?

助けてください....

私はそれがうまく動作しています。すべての表の行がスクロールしており、表のヘッダーが固定されています。 しかし、テーブルの最後までスクロールすると、修正のプロパティが失われます。私は境界線のスクロールを意味します。私はそれを絶対に凍結したい。境界条件では、テーブルの上部位置が緩み、約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; 
} 

答えて

2

私があなたの質問を正しく理解していれば、テーブルがバウンスしないようにする必要があるように思えます。そのような場合は、viewDidLoad関数にyourTable.bounces = NO;と設定するだけです。テーブルをレイアウトするために使用した場合は、NIBの "Bounces"オプションのチェックを外してください。

あなたの編集で言及した問題を解決する方法は次のとおりです。tableView.headerViewへの次の参照を、デリゲートメソッドに渡されない新しいビューへの参照で置き換える必要があります。

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

私はそれを試してみて、それは私のためのトリックでした。希望が役立ちます。

関連する問題