Ios UITableView节索引重叠行删除按钮

Ios UITableView节索引重叠行删除按钮,ios,objective-c,uitableview,ios7,Ios,Objective C,Uitableview,Ios7,在谷歌、Stackoverflow和苹果的文档中搜索了很多之后,我几乎放弃了 我正在制作一个为客户编制索引的应用程序,由于可能有一个很长的列表,我使用节索引来更快地导航。我的问题如下图所示 当我拖动项目以显示“删除”按钮时,它部分隐藏在我的节索引栏下方 就我而言,我没有设置tableview或tableviewcells宽度的代码,并且节索引实际上无法更改 编辑: 问题是如何让tableview单元格在重叠之前结束,从而使“删除”按钮完全可见 编辑2: 我已经试着把牢房的框架缩小了,但没有任何

在谷歌、Stackoverflow和苹果的文档中搜索了很多之后,我几乎放弃了

我正在制作一个为客户编制索引的应用程序,由于可能有一个很长的列表,我使用节索引来更快地导航。我的问题如下图所示

当我拖动项目以显示“删除”按钮时,它部分隐藏在我的节索引栏下方

就我而言,我没有设置tableview或tableviewcells宽度的代码,并且节索引实际上无法更改

编辑:

问题是如何让tableview单元格在重叠之前结束,从而使“删除”按钮完全可见

编辑2:

我已经试着把牢房的框架缩小了,但没有任何运气

cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y, cell.frame.size.width-30, cell.frame.size.height);
我也对tableview进行了同样的尝试,但由于它位于UITableViewController中,因此无法调整其大小

self.tableView.frame = CGRectMake(self.tableView.frame.origin.x, self.tableView.frame.origin.y, self.tableView.frame.size.width-30, self.tableView.frame.size.height);

作为一个简单的解决方法,我们通过将索引的背景色设置为clearColor来解决索引的视觉重叠问题

self.tableView.sectionIndexBackgroundColor = [UIColor clearColor];
*这看起来视觉效果更好,但索引仍将与tableViewCell重叠

另一种可能的解决方法是在进入编辑模式时隐藏索引栏:

// allow editing
[self.tableView setEditing:YES animated:YES];
// hides the index
self.tableView.sectionIndexMinimumDisplayRowCount = NSIntegerMax;

inEditMode
方法应该可以做到这一点。下面我嵌入了一个完整的代码,它在编辑时隐藏索引,在编辑完成后再次显示索引

-(void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath{
    [self inEditMode:YES];
}

-(void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath{
    [self inEditMode:NO];
}
//on self.editButtonItem click
-(void)setEditing:(BOOL)editing animated:(BOOL)animated{
    [super setEditing:editing animated:animated];
    [self inEditMode:editing];
}

-(void)inEditMode:(BOOL)inEditMode{
    if (inEditMode) { //hide index while in edit mode
        self.tableView.sectionIndexMinimumDisplayRowCount = NSIntegerMax;
    }else{
         self.tableView.sectionIndexMinimumDisplayRowCount = NSIntegerMin;
    }
    [self.tableView reloadSectionIndexTitles];
}

在cellForRowAtIndexPath中分配任何子视图之前,只需使用此代码

for (id object in cell.contentView.subviews)
{
    [object removeFromSuperview];
}  

那么…你是在问如何改变剖面索引条的宽度?如何移动删除按钮使其不被覆盖?你只是陈述了一个问题,毫无疑问我现在添加了一个更具体的问题。现在我的意图更清楚了吗?它可能为苹果创建了一个bug报告。在修复之前,必须这样做。只需有条件地为iOS 7添加代码即可。快速的SO搜索将提供多种检测iOS版本的方法。