UITableView节索引重叠行删除button

经过Google,Stackoverflow和苹果文档的search后,我几乎放弃了。

我正在制作一个应用程序来索引用户,由于潜在的很长的列表,我使用部分索引更快地导航。 我的问题如下图所示。

http://i.stack.imgur.com/i2tTx.png

当我拖动一个项目来显示删除button,它是部分隐藏在我的部分索引栏下面。

我没有代码设置tableview或tableviewcells宽度和部分索引不能真正改变,就我而言。

编辑:

问题是我如何才能让tableview单元格在重叠之前结束,因此删除button是完全可见的。

编辑2:

我已经尝试设置更小的单元格没有任何运气。

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

我也尝试过与tableview相同,但它是在UITableViewController它不能被resize。

 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方法应该做的伎俩。 下面我embedded一个完整的代码,在编辑时隐藏索引,并在编辑完成后再次显示。

 -(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]; }