Iphone 如何在仍然使用reorder的情况下摆脱reorderControl?
不久前,reorderControl视图靠近我的自定义单元格的中心,因此此reorderControl打破了自定义设计。由于我无法移动此视图,并且我的单元格始终处于编辑模式,所以我只需在单元格背景的正确位置绘制此Reorder控件。但现在我有两个ReorderControl)一个来自正确位置的后台,一个来自iOS。如果我将Iphone 如何在仍然使用reorder的情况下摆脱reorderControl?,iphone,ios,ios4,uitableview,Iphone,Ios,Ios4,Uitableview,不久前,reorderControl视图靠近我的自定义单元格的中心,因此此reorderControl打破了自定义设计。由于我无法移动此视图,并且我的单元格始终处于编辑模式,所以我只需在单元格背景的正确位置绘制此Reorder控件。但现在我有两个ReorderControl)一个来自正确位置的后台,一个来自iOS。如果我将-(BOOL)tableView:(UITableView*)tableView canEditRowAtIndexPath:(nsindepath*)indepath的返回值
-(BOOL)tableView:(UITableView*)tableView canEditRowAtIndexPath:(nsindepath*)indepath
的返回值设置为NO,iOS reorderControl将消失,但我无法再对行重新排序
如何从屏幕上删除iOS reorderControl,并且仍然能够对自定义UITableViewCell进行重新排序
ps cell.showsReorderControl=否;不起作用这是一种黑客行为,但以下方法确实有效
for(UIView* view in self.subviews)
{
if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"])
{
for(UIImageView* cellGrip in view.subviews)
{
if([cellGrip isKindOfClass:[UIImageView class]])
[cellGrip setImage:nil];
}
}
}
我在iOS7中得到的解决方案是添加另一个方法来查找重新排序控件。由于在iOS7中tableview结构发生了更改,因此跟踪
UITableViewCellReorderControl
有点困难。它现在位于UITableViewCellScrollView
中
解决方案如下所示
- (void)changeReorderControl:(UITableViewCell *)cell subviewCell:(UIView *)subviewCell
{
if([[[subviewCell class] description] isEqualToString:@"UITableViewCellReorderControl"]) {
[subviewCell.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
UIImageView *imageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hand"]];
imageView.center = CGPointMake(subviewCell.frame.size.width/2 , subviewCell.frame.size.height/2);
[subviewCell addSubview:imageView];
}
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
for(UIView* subviewCell in cell.subviews)
{
if([[[subviewCell class] description] isEqualToString:@"UITableViewCellScrollView"]) {
for(UIView* subSubviewCell in subviewCell.subviews) {
[self changeReorderControl:cell subviewCell:subSubviewCell];
}
}
}
}
希望你能明白