0

我正在删除具有 UIImage 视图的 UITableView 中的单元格。当我滑动删除时,删除按钮在 UIView 后面,如果 UIView 在删除按钮后面会更好看。有没有办法可以将按钮的图层首选项设置在顶部?

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
   NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];

    [context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];



    //Deletes view from cell
    for (UIView *subview in [self.view subviews]) {

        if (subview != self.tableView) {
            [subview removeFromSuperview];
        }
    }

    NSError *error = nil;
    if (![context save:&error]) {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }
}
[self performFetch];


}
4

1 回答 1

0

我认为您已将子视图(包括您的 UIImageView)直接放在单元格的子视图中,而不是在 contentView 中。

尝试将它们添加到 contentView 中。

您是否将单元格子类化并在 init 方法中添加了视图?然后使用:

[[self contentView] addSubview:myImageView];

你没有子类化单元格并且你在你的 ViewController 中添加了 UIImageView 吗?

[[cell contentView] addSubview:myImageView];

当显示删除按钮时,这将导致包含您的图像的 contentView 缩小。

如果你真的想把它放在按钮后面,试着把它移到后面的某个地方。

[self sendSubviewToBack:myImageView];
于 2013-01-04T19:17:25.680 回答