ボタンをクリックすると(上/下)、一度に1行ずつトラバースするUIImageViewを持つUITableViewがあります。私が今やりたいことは、ユーザーが UIImageView をテーブルの上または下にのみドラッグできるようにすることです (つまり、横方向の動きはありません)。UIImageView の大部分が特定のセル上にある場合、ユーザーが指を離したときに、UIImageView をその行にリンクさせます。UIImageView を使用した UITableView のイメージを次に示します。
スクロールバーは、移動または下に移動する必要がある UIImageView です。次のメソッドを実装することになっていることを認識しています。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// We only support single touches, so anyObject retrieves just that touch from touches.
UITouch *touch = [touches anyObject];
if ([touch view] != _imageView) {
return;
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == _imageView) {
return;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
//here is where I guess I need to determine which row contains majority of the scrollbar. This would only measure the y coordinate value, and not the x, since it will only be moving up or down.
return;
}
}
ただし、この機能を実現する方法がわかりません。同様の例をオンラインで見つけようとしましたが、Apple の MoveMe のサンプル コードも調べましたが、まだ行き詰っています。私のスクロールバーはテーブルの行とまったく同じサイズではなく、少し長くても同じ高さであることにも注意してください。
回答者全員に事前に感謝します