0

如何在 iPad 上的 iOS 7 上的 UITableView 单元格右侧绘制图像?

尝试并没有帮助以下代码:

  1. tableView.contentInset = UIEdgeInsetsZero;
  2. [cell contentView].frame = CGRectMake(0, [cell contentView].frame.origin.y, cell.frame.size.width, [cell contentView].frame.size.height);
4

1 回答 1

2

您很可能希望将accessoryView属性设置在UITableViewCell. 这将在单元格的右侧放置一个图像视图:

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

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        // Configure cell
    }

    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<some image name>.png"]];
    cell.accessoryView = image;
}
于 2013-09-13T21:55:50.477 回答