Ios 防止顶部UiTableViewCell滚动

Ios 防止顶部UiTableViewCell滚动,ios,objective-c,uitableview,ios7,Ios,Objective C,Uitableview,Ios7,我有一个tableView,我使用第一个单元格作为表格的过滤按钮。单击后,将显示UiPickerView 有没有办法防止第一个单元格与表格的其余部分一起滚动,并在导航栏下保持静止 我的表格视图: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * teamCellIndentifier = @"al

我有一个tableView,我使用第一个单元格作为表格的过滤按钮。单击后,将显示UiPickerView

有没有办法防止第一个单元格与表格的其余部分一起滚动,并在导航栏下保持静止

我的表格视图:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString * teamCellIndentifier   = @"allEventsCell";
static NSString * filterCell            = @"filterCell";
UIColor *separator                      = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:223/255.0f alpha:1];
UIColor *subtitle                       = [UIColor colorWithRed:100/255.0f green:100/255.0f blue:100/255.0f alpha:1];

if(indexPath.row != 0)
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:teamCellIndentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:teamCellIndentifier];
    }


    cell.textLabel.font                     = [UIFont fontWithName:@"HelveticaNeue" size:16.0];
    cell.textLabel.backgroundColor          = [UIColor clearColor];
    cell.textLabel.highlightedTextColor     = kPointstreakBlueColor;
    cell.textLabel.textColor                = subtitle;
    cell.accessoryType                      = UITableViewCellAccessoryDisclosureIndicator;
    cell.detailTextLabel.font                 = [UIFont fontWithName:@"HelveticaNeue" size:12.0];
    cell.detailTextLabel.backgroundColor      = [UIColor clearColor];
    cell.detailTextLabel.highlightedTextColor = kPointstreakBlueColor;
    cell.detailTextLabel.textColor            = subtitle;

    [self.tableView setSeparatorColor:separator];

    VideoClipData   * gameVideos    = [gameJsondataEventAry objectAtIndex:indexPath.row];
    VideoClip       * gameVideoData = [gameEventAry objectAtIndex:indexPath.row];

    // date formatting
    NSString        * str           = gameVideoData.evtCreatedSrt;
    NSDateFormatter * dateFormat    = [[NSDateFormatter alloc] init];
    NSLocale        * usLocale      = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];

    [dateFormat setLocale:usLocale];
    [dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];

    NSDate * dte = [dateFormat dateFromString:str];
    [dateFormat setDateFormat:@"MMM dd, YYYY - hh:mma"];

    cell.textLabel.text = gameVideos.evtTitleStr;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",[dateFormat stringFromDate:dte]];

    return cell;
}
else
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:filterCell];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:filterCell];
    }

    if(self.toggle == 0)
    {
        cell.textLabel.font                     = [UIFont fontWithName:@"HelveticaNeue" size:16.0];
        cell.backgroundColor                    = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor     = kPointstreakBlueColor;
        cell.textLabel.textColor                = subtitle;
        cell.textLabel.textAlignment            = NSTextAlignmentCenter;
        cell.textLabel.text = @"Filter Events";
        return cell;
    }
    else
    {
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        cell.textLabel.textColor     = [UIColor redColor];
        cell.textLabel.text          = @"Cancel";
        return cell;
    }
}
}

谢谢你的关注

更新:

我可以制作一个可点击的标题,如下所示:

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView * headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 22)];
    UILabel* headerLabel = [[UILabel alloc] init];
    headerLabel.frame = CGRectMake(5, 2, tableView.frame.size.width - 5, 18);
    headerLabel.font = [UIFont boldSystemFontOfSize:16.0];
    headerLabel.text = @"Filter Evnets";
    headerLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bringUpPickerViewWithRow:)];
    [headerLabel addGestureRecognizer:tapGesture];

    [headerView addSubview:headerLabel];

    return headerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 70;
}

您应该将其设置为节标题,而不是第一个单元格。如果您有多个分区,您将希望它成为自己的视图(而不是表视图的一部分)。

您应该将其设置为分区标题,而不是第一个单元格。如果您有多个分区,您将希望它成为自己的视图(而不是表视图的一部分)。

您应该将其设置为分区标题,而不是第一个单元格。如果您有多个分区,您将希望它成为自己的视图(而不是表视图的一部分)。

您应该将其设置为分区标题,而不是第一个单元格。如果您有多个分区,则希望它成为自己的视图(而不是表视图的一部分)。

如果您的表视图中只有一个分区,则可以使用分区标题。它将固定在表的顶部。如果表视图中只有一个节,则可以使用节标题。它将固定在表的顶部。如果表视图中只有一个节,则可以使用节标题。它将固定在表的顶部。如果表视图中只有一个节,则可以使用节标题。它将固定在桌子的顶部。