UITableView Section Index重叠行删除按钮 [英] UITableView Section Index overlapping row delete button
问题描述
经过大量搜索谷歌,Stackoverflow和苹果文档,我几乎放弃了。
After quite a lot searching around Google, Stackoverflow and apples documentation, I have almost given up.
我正在制作一个应用程序来索引客户,因为有潜力非常长的列表,我使用节索引来更快地导航。我的问题如下图所示。
I am making an app to index costumers and because of a potentially very long list, I use section index to navigate faster. My problem is shown in the picture below.
当我拖动项目以显示删除按钮时,它部分隐藏在我的部分索引栏下方。
When I drag an item to reveal the delete button, it is partially hidden below my section index bar.
我没有代码设置tableview或tableviewcells宽度,并且就我而言,部分索引无法真正改变。
I have no code setting tableview or tableviewcells width and the section index can't really be changed, as far as i am concerned.
编辑:
问题是如何让tableview单元格在重叠之前结束,因此删除按钮完全可见。
The question is how I can have the tableview cells end before they get overlapped, so the delete button is fully visible.
编辑2:
我已经尝试将单元格框设置得更小而没有任何运气。
I already tried setting the cell frame smaller without any luck.
cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y, cell.frame.size.width-30, cell.frame.size.height);
我也尝试了同样的tableview,但因为它在UITableViewController中,所以无法调整大小。
I also tried the same with the tableview, but as it is in a UITableViewController it cannot be resized.
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。
As a simple work-around we resolved the visual overlap of the index by setting the background color of the index to clearColor.
self.tableView.sectionIndexBackgroundColor = [UIColor clearColor];
*这在视觉上看起来更好,但索引仍会与tableViewCell重叠。
* This looks visually better, but the index will still overlap your tableViewCell.
另一种可能的解决方法是在进入编辑模式时隐藏索引栏:
Another possible work-around would be to hide the index bar when entering edit mode:
// allow editing
[self.tableView setEditing:YES animated:YES];
// hides the index
self.tableView.sectionIndexMinimumDisplayRowCount = NSIntegerMax;
这篇关于UITableView Section Index重叠行删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!