0

さまざまなエントリを持つTableViewがあります。下にスクロールする必要がある場合もあれば、エントリが少ない場合もあるため、すべてが表示されます。

最初のセルにいくつかの設定とフィルターが必要ですが、ユーザーが下にスクロールしたときにのみ表示されないようにする必要があります。

私の試み:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    float rowHeight = [self tableView:self.tableView heightForRowAtIndexPath:indexPath];
    self.tableView.contentOffset = CGPointMake(0, rowHeight);
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTopanimated:NO];

}

両方とも機能しませんでした。

私の問題について何かアドバイスはありますか?

4

3 に答える 3

1

Are you looking for something like this?

[self.tableView setContentInset:UIEdgeInsetsMake(t,l,b,r)];

this will shift your tableView whatever way you want, but you can definitely scroll back.

于 2012-08-22T07:05:07.037 に答える
0

TableView Delegate メソッドでロジックを試してください

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"セル";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    もし (セル == ゼロ)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    if (indexPath.row == 0) {
        //ここにフィルター
    }
    そうしないと {
        //セルを表示する
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    セルを返します。
}

また、最初のセルを表示したくない場合は、次のように記述してください

ゼロを返します。//indexpath.row == 0 の条件の場合

また、行の高さを調整します

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

    if (section == 0 && isDisplayThisSection) {//最初に表示

        UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 5, 320, 25)] autorelease];

        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(17, 10, 300, 25)];

        [titleLabel setFont:[UIFont boldSystemFontOfSize:17.0]];

        titleLabel.text = @"一時テスト";

        [titleLabel setBackgroundColor:[UIColor clearColor]];

        [headerView addSubview:titleLabel];

        [titleLabel リリース];

        [headerView setBackgroundColor:[UIColor clearColor]];

        headerView を返します。

    }
    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease];

}

値を 0 に設定

この助けを願っています!!

于 2012-08-22T07:16:43.597 に答える
-1

TableView Delegate メソッドでロジックを試してください

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"セル";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    もし (セル == ゼロ)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    if (indexPath.row == 0) {
        //ここにフィルター
    }
    そうしないと {
        //セルを表示する
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    セルを返します。
}

また、最初のセルを表示したくない場合は、次のように記述してください

戻る ; //indexpath.row == 0 の条件の場合

また、行の高さを調整します

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

値を 0 に設定

そして、Pull_to_Refresh のように実装したい場合は、ロジックを次のように記述したほうがよいでしょう。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;

この助けを願っています!!

于 2012-08-22T07:02:54.403 に答える