小编ric*_*cht的帖子

如何在UITableView的顶部添加额外的分隔符?

我有一个基本上分为两部分的iPhone视图,上半部分有一个信息显示,下半部分有一个用于选择动作的UITableView.问题是UITableView中第一个单元格上方没有边框或分隔符,因此列表中的第一个项目看起来很有趣.如何在表格顶部添加额外的分隔符,将其与上方的显示区域分开?

这是构建单元格的代码 - 它非常简单.整体布局在xib中处理.

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    switch(indexPath.row) {
        case 0: {
            cell.textLabel.text = @"Action 1";
            break;
        }
        case 1: {
            cell.textLabel.text = @"Action 2";
            break;
        }
        // etc.......
    }
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uikit ios

34
推荐指数
5
解决办法
2万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

iphone ×1

objective-c ×1

uikit ×1