gpt4 book ai didi

ios - 防止顶部 UiTableViewCell 滚动

转载 作者:行者123 更新时间:2023-11-28 19:58:16 25 4
gpt4 key购买 nike

我有一个 tableView,我使用第一个单元格作为表格的筛选器按钮。一旦点击 UiPickerView 出现。

有没有办法让第一个单元格不随表格的其余部分滚动并在导航栏下保持静止?

我的表格 View :

- (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;
}

最佳答案

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

关于ios - 防止顶部 UiTableViewCell 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25296570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com