このチュートリアルを使用して、並べ替えボタンがセル全体をカバーするようにしようとしています。セルがビューから消えるまでうまく機能します。セルに戻ると、並べ替えボタンがかなり移動しています。
この図では、赤は再注文ボタンを表しています。
チュートリアルで使用するコードは次のとおりです。
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Grip customization code goes in here...
for(UIView* view in cell.subviews)
{
if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"])
{
UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), CGRectGetMaxY(view.frame))];
[resizedGripView addSubview:view];
[cell addSubview:resizedGripView];
[resizedGripView release];
CGSize sizeDifference = CGSizeMake(resizedGripView.frame.size.width - view.frame.size.width, resizedGripView.frame.size.height - view.frame.size.height);
CGSize transformRatio = CGSizeMake(resizedGripView.frame.size.width / view.frame.size.width, resizedGripView.frame.size.height / view.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 view.subviews)
{
if([cellGrip isKindOfClass:[UIImageView class]])
[cellGrip setImage:nil];
}
}
}
}
並べ替えコントロールが左に移動しないようにするにはどうすればよいですか? 変換を再度変換しようとしましたが、並べ替えコントロールが完全に画面から外れてしまいます。左に移動するコードの何が問題なのですか?どうすれば修正できますか?