【发布时间】:2014-02-26 07:19:25
【问题描述】:
我想点击每个单元格来激活push segue,但因为view controller 始终处于编辑模式,我无法点击单元格。在editing mode 中,我放大了reorder controller 以覆盖整个cell,然后使其不可见,因此您可以从单元格中的任何位置拖动以重新排序tableview,因此当我在编辑模式下单击单元格时,我'我实际上是在点击重新排序控制器。请不要告诉我将 allowsSelectionDuringEditing 的 tableview 属性设置为 YES,因为我已经这样做了,它仍然不允许我选择单元格,因为它被作为子视图添加到单元格的重新排序控制器所覆盖.
我的解决方案是通过cell 中的tap 手势准备一个新的push segue,即使该单元格被其reorder controller 覆盖,它仍然会激活。但是,无论我单击哪个单元格,发送到segue 调用的view 的数据始终来自第一个cell。为什么会发生这种情况?任何帮助表示赞赏。
这就是我更改重新排序控制的方式
-(void) resizeReorderControl: (UITableView *)tableView reorderCell:(UITableViewCell *)bCell{
// Grip customization code goes in here...
UIView* reorderControl = [bCell huntedSubviewWithClassName:@"UITableViewCellReorderControl"];
UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(reorderControl.frame), CGRectGetMaxY(reorderControl.frame))];
[resizedGripView addSubview:reorderControl];
[bCell addSubview:resizedGripView];
CGSize sizeDifference = CGSizeMake(resizedGripView.frame.size.width - reorderControl.frame.size.width, resizedGripView.frame.size.height - reorderControl.frame.size.height);
CGSize transformRatio = CGSizeMake(resizedGripView.frame.size.width / reorderControl.frame.size.width, resizedGripView.frame.size.height / reorderControl.frame.size.height);
// Original transform
CGAffineTransform transform = CGAffineTransformIdentity;
// Scale custom view so grip will fill entire cell
transform = CGAffineTransformScale(transform, transformRatio.width, transformRatio.height);
// Move custom view so the grip's top left aligns with the cell's top left
transform = CGAffineTransformTranslate(transform, -sizeDifference.width / 2.0, -sizeDifference.height / 2.0);
[resizedGripView setTransform:transform];
for(UIImageView* cellGrip in reorderControl.subviews)
{
if([cellGrip isKindOfClass:[UIImageView class]])
[cellGrip setImage:nil];
}
}
【问题讨论】:
标签: ios objective-c uitableview