iOS 在动态表格的顶部创建一个静态单元格

标签 ios xcode uitableview dynamic

标题已经说明了一切。如何在动态表格顶部创建一个静态单元格?我希望能够将它用作我的表格的图例。谢谢。

这是我的 tableView 代码:

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

static NSString *CellIdentifier = @"Cell";
JointCAD *currentCall = [[xmlParser calls] objectAtIndex:indexPath.row];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"texture3.png"]];

TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
{
    cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    UIView *selectionView = [[UIView alloc] initWithFrame:CGRectMake(10, 7, 200, 65)];
    [selectionView setBackgroundColor: [UIColor clearColor]];
    cell.selectedBackgroundView = selectionView;
}

cell.callTypeLabel.text = currentCall.currentCallType;
cell.locationLabel.text = currentCall.location;
cell.unitsLabel.text = currentCall.units;
cell.stationLabel.text = [@"Station: " stringByAppendingString:currentCall.station];

if ([currentCall.callType isEqualToString:@"F"]) {
    cell.imageType = Fire;
}
else {
    cell.imageType = EMS;
}

if ([currentCall.county isEqualToString:@"W"]) {
    cell.imageType1 = Washington;
}
else {
    cell.imageType1 = Clackamas;
}

return cell;

}

最佳答案

这看起来更像是您想要表格的标题,而不是静态单元格。如果我理解您的问题,您需要一个位于顶部且不移动的单元格,而动态部分中的其他单元格按正常情况上下滚动。

如果是这种情况,请使用返回 header View 及其大小的 tableviewdelegate 方法。

如果不是这种情况,那么我不明白你的问题,抱歉。

关于iOS 在动态表格的顶部创建一个静态单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12683735/

相关文章:

ios - 文本标签未根据 ScrollView SwiftUI 中的字符串扩展

iOS Swift 动画 - 将图像移动到新位置

ios - 更改自定义单元格内容 View 颜色

ios - 为 UITableViewCell 绘制虚线边框底部

ios - 在 iOS8 中使用 Swift 点击时如何隐藏/显示 tabBar

ios - 调用SKPaymentQueue restoreCompletedTransactions,无响应

iOS AVPlayerViewController 不显示播放控件

iphone - 为视网膜 iPhone 开发应用程序/游戏

ios - 自 Xcode 8 以来 UI 测试速度变慢

IOS:选择时将 UITableView 中的选定项目显示到 UItextField