iPhone视图单元-角三角形
有没有人看到过一个片段(或类/库),它将在tableview单元格中绘制那个三角角(参见下图)iPhone视图单元-角三角形,iphone,ios,tableviewcell,Iphone,Ios,Tableviewcell,有没有人看到过一个片段(或类/库),它将在tableview单元格中绘制那个三角角(参见下图) 它可能只是细胞中的一个图像。没什么特别的,只是您的标准普通定制UITableViewCell您可以从图像创建一个新视图,然后将其添加到调用addSubview的单元格中。以下是启动时设置拐角的示例: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
它可能只是细胞中的一个图像。没什么特别的,只是您的标准普通定制
UITableViewCell
您可以从图像创建一个新视图,然后将其添加到调用addSubview的单元格中。以下是启动时设置拐角的示例:
- (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];
CGRect cornerFrame = CGRectMake(x, y, width, height);
UIImageView * corner = [[UIImageView alloc] initWithFrame:cornerFrame];
[corner setImage:[UIImage imageNamed:@"corner.jpg"]];
[cell.contentView addSubview:corner];
}
return cell;
}
它是内置的
UITableViewCell
简单
cell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
这将无法正常工作…单元格将被重用,如果以这种方式实现,您将向每个单元格中添加许多这样的单元格。这是调用
addSubview
的突出示例。他可以在任何他想要的地方使用它。在这个特殊的地方,它会被打破:)唯一比没有代码样本更糟糕的事情是一个糟糕的代码样本。真的吗?因为我有这样的实现,它们可以工作。也许我一直都错了。我可能应该选择其他单元格标识符。更改了源,现在修复了吗?=)