100枚の画像があります(a400e3x_0.png、.....、a400e3x_98.png、a400e3x_99.png)。これらの画像は、ユーザーが制御できるアニメーションのように、UIImageView のスワイプに応じて変化します。問題は、ユーザーがパンを停止してから再開すると、アニメーションが画像 0 に戻ることです。ユーザーがパンを停止したときの位置を保存する必要があります。しかし、それを追加すると、追加は常にそこにあります。例: 画像 16 でパンを停止し、16 から再開します。(curX%100) がゼロの場合でも、常に 16 が追加されます。このためのアルゴリズムを教えてください。
- (IBAction)PanGesAction:(id)sender
{
CGPoint translation = [_PanGes translationInView:self.view];
int curX = (int)translation.x;
addition = (curX%100)+Savedif;
NSLog(@"%d", addition);
[_ImageV2 setImage:[UIImage imageNamed:[NSString stringWithFormat:@"a400e3x_%d.png", addition]]];
if (_PanGes.state == UIGestureRecognizerStateEnded)
{
NSLog(@"End");
Savedif = addition;
//When user end
}
if (_PanGes.state == UIGestureRecognizerStateBegan)
{
NSLog(@"Began");
//When user begin
}
}